AutoUpgrade.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- AutoUpgrade.h - AutoUpgrade Helpers ----------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // These functions are implemented by lib/IR/AutoUpgrade.cpp.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_IR_AUTOUPGRADE_H
  18. #define LLVM_IR_AUTOUPGRADE_H
  19. #include "llvm/ADT/StringRef.h"
  20. namespace llvm {
  21. class AttrBuilder;
  22. class CallInst;
  23. class Constant;
  24. class Function;
  25. class Instruction;
  26. class MDNode;
  27. class Module;
  28. class GlobalVariable;
  29. class Type;
  30. class Value;
  31. /// This is a more granular function that simply checks an intrinsic function
  32. /// for upgrading, and returns true if it requires upgrading. It may return
  33. /// null in NewFn if the all calls to the original intrinsic function
  34. /// should be transformed to non-function-call instructions.
  35. bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn);
  36. /// This is the complement to the above, replacing a specific call to an
  37. /// intrinsic function with a call to the specified new function.
  38. void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn);
  39. // This upgrades the comment for objc retain release markers in inline asm
  40. // calls
  41. void UpgradeInlineAsmString(std::string *AsmStr);
  42. /// This is an auto-upgrade hook for any old intrinsic function syntaxes
  43. /// which need to have both the function updated as well as all calls updated
  44. /// to the new function. This should only be run in a post-processing fashion
  45. /// so that it can update all calls to the old function.
  46. void UpgradeCallsToIntrinsic(Function* F);
  47. /// This checks for global variables which should be upgraded. It it requires
  48. /// upgrading, returns a pointer to the upgraded variable.
  49. GlobalVariable *UpgradeGlobalVariable(GlobalVariable *GV);
  50. /// This checks for module flags which should be upgraded. It returns true if
  51. /// module is modified.
  52. bool UpgradeModuleFlags(Module &M);
  53. /// Convert calls to ARC runtime functions to intrinsic calls and upgrade the
  54. /// old retain release marker to new module flag format.
  55. void UpgradeARCRuntime(Module &M);
  56. void UpgradeSectionAttributes(Module &M);
  57. /// Correct any IR that is relying on old function attribute behavior.
  58. void UpgradeFunctionAttributes(Function &F);
  59. /// If the given TBAA tag uses the scalar TBAA format, create a new node
  60. /// corresponding to the upgrade to the struct-path aware TBAA format.
  61. /// Otherwise return the \p TBAANode itself.
  62. MDNode *UpgradeTBAANode(MDNode &TBAANode);
  63. /// This is an auto-upgrade for bitcast between pointers with different
  64. /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr.
  65. Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
  66. Instruction *&Temp);
  67. /// This is an auto-upgrade for bitcast constant expression between pointers
  68. /// with different address spaces: the instruction is replaced by a pair
  69. /// ptrtoint+inttoptr.
  70. Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
  71. /// Check the debug info version number, if it is out-dated, drop the debug
  72. /// info. Return true if module is modified.
  73. bool UpgradeDebugInfo(Module &M);
  74. /// Check whether a string looks like an old loop attachment tag.
  75. inline bool mayBeOldLoopAttachmentTag(StringRef Name) {
  76. return Name.startswith("llvm.vectorizer.");
  77. }
  78. /// Upgrade the loop attachment metadata node.
  79. MDNode *upgradeInstructionLoopAttachment(MDNode &N);
  80. /// Upgrade the datalayout string by adding a section for address space
  81. /// pointers.
  82. std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple);
  83. /// Upgrade attributes that changed format or kind.
  84. void UpgradeAttributes(AttrBuilder &B);
  85. } // End llvm namespace
  86. #endif
  87. #ifdef __GNUC__
  88. #pragma GCC diagnostic pop
  89. #endif