LLVM  15.0.0git
AutoUpgrade.h
Go to the documentation of this file.
1 //===- AutoUpgrade.h - AutoUpgrade Helpers ----------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // These functions are implemented by lib/IR/AutoUpgrade.cpp.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_IR_AUTOUPGRADE_H
14 #define LLVM_IR_AUTOUPGRADE_H
15 
16 #include "llvm/ADT/StringRef.h"
17 #include <vector>
18 
19 namespace llvm {
20  class AttrBuilder;
21  class CallBase;
22  class Constant;
23  class Function;
24  class Instruction;
25  class GlobalVariable;
26  class MDNode;
27  class Module;
28  class StringRef;
29  class Type;
30  class Value;
31 
32  template <typename T> class OperandBundleDefT;
34 
35  /// This is a more granular function that simply checks an intrinsic function
36  /// for upgrading, and returns true if it requires upgrading. It may return
37  /// null in NewFn if the all calls to the original intrinsic function
38  /// should be transformed to non-function-call instructions.
40 
41  /// This is the complement to the above, replacing a specific call to an
42  /// intrinsic function with a call to the specified new function.
43  void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn);
44 
45  // This upgrades the comment for objc retain release markers in inline asm
46  // calls
47  void UpgradeInlineAsmString(std::string *AsmStr);
48 
49  /// This is an auto-upgrade hook for any old intrinsic function syntaxes
50  /// which need to have both the function updated as well as all calls updated
51  /// to the new function. This should only be run in a post-processing fashion
52  /// so that it can update all calls to the old function.
54 
55  /// This checks for global variables which should be upgraded. It it requires
56  /// upgrading, returns a pointer to the upgraded variable.
58 
59  /// This checks for module flags which should be upgraded. It returns true if
60  /// module is modified.
62 
63  /// Convert calls to ARC runtime functions to intrinsic calls and upgrade the
64  /// old retain release marker to new module flag format.
65  void UpgradeARCRuntime(Module &M);
66 
68 
69  /// Correct any IR that is relying on old function attribute behavior.
71 
72  /// If the given TBAA tag uses the scalar TBAA format, create a new node
73  /// corresponding to the upgrade to the struct-path aware TBAA format.
74  /// Otherwise return the \p TBAANode itself.
75  MDNode *UpgradeTBAANode(MDNode &TBAANode);
76 
77  /// This is an auto-upgrade for bitcast between pointers with different
78  /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr.
79  Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
80  Instruction *&Temp);
81 
82  /// This is an auto-upgrade for bitcast constant expression between pointers
83  /// with different address spaces: the instruction is replaced by a pair
84  /// ptrtoint+inttoptr.
85  Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
86 
87  /// Check the debug info version number, if it is out-dated, drop the debug
88  /// info. Return true if module is modified.
89  bool UpgradeDebugInfo(Module &M);
90 
91  /// Check whether a string looks like an old loop attachment tag.
93  return Name.startswith("llvm.vectorizer.");
94  }
95 
96  /// Upgrade the loop attachment metadata node.
97  MDNode *upgradeInstructionLoopAttachment(MDNode &N);
98 
99  /// Upgrade the datalayout string by adding a section for address space
100  /// pointers.
101  std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple);
102 
103  /// Upgrade attributes that changed format or kind.
104  void UpgradeAttributes(AttrBuilder &B);
105 
106  /// Upgrade operand bundles (without knowing about their user instruction).
107  void UpgradeOperandBundles(std::vector<OperandBundleDef> &OperandBundles);
108 
109 } // End llvm namespace
110 
111 #endif
llvm::upgradeInstructionLoopAttachment
MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
Definition: AutoUpgrade.cpp:4601
llvm::UpgradeCallsToIntrinsic
void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
Definition: AutoUpgrade.cpp:4103
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::UpgradeIntrinsicFunction
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn)
This is a more granular function that simply checks an intrinsic function for upgrading,...
Definition: AutoUpgrade.cpp:1046
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::UpgradeDebugInfo
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
Definition: AutoUpgrade.cpp:4187
llvm::Function
Definition: Function.h:60
StringRef.h
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::OperandBundleDefT
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: AutoUpgrade.h:32
llvm::UpgradeOperandBundles
void UpgradeOperandBundles(std::vector< OperandBundleDef > &OperandBundles)
Upgrade operand bundles (without knowing about their user instruction).
Definition: AutoUpgrade.cpp:4679
llvm::UpgradeAttributes
void UpgradeAttributes(AttrBuilder &B)
Upgrade attributes that changed format or kind.
Definition: AutoUpgrade.cpp:4652
llvm::mayBeOldLoopAttachmentTag
bool mayBeOldLoopAttachmentTag(StringRef Name)
Check whether a string looks like an old loop attachment tag.
Definition: AutoUpgrade.h:92
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::UpgradeARCRuntime
void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
Definition: AutoUpgrade.cpp:4237
llvm::UpgradeBitCastInst
Instruction * UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, Instruction *&Temp)
This is an auto-upgrade for bitcast between pointers with different address spaces: the instruction i...
Definition: AutoUpgrade.cpp:4143
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::UpgradeTBAANode
MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
Definition: AutoUpgrade.cpp:4121
llvm::Instruction
Definition: Instruction.h:42
llvm::UpgradeSectionAttributes
void UpgradeSectionAttributes(Module &M)
Definition: AutoUpgrade.cpp:4484
llvm::UpgradeFunctionAttributes
void UpgradeFunctionAttributes(Function &F)
Correct any IR that is relying on old function attribute behavior.
Definition: AutoUpgrade.cpp:4541
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::UpgradeIntrinsicCall
void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn)
This is the complement to the above, replacing a specific call to an intrinsic function with a call t...
Definition: AutoUpgrade.cpp:1942
TemplateParamKind::Type
@ Type
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:937
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::UpgradeBitCastExpr
Value * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
Definition: AutoUpgrade.cpp:4165
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::UpgradeModuleFlags
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
Definition: AutoUpgrade.cpp:4358
N
#define N
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
llvm::UpgradeInlineAsmString
void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
Definition: AutoUpgrade.cpp:1841
llvm::UpgradeGlobalVariable
GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
Definition: AutoUpgrade.cpp:1059
llvm::UpgradeDataLayoutString
std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
Definition: AutoUpgrade.cpp:4617
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::codeview::PublicSymFlags::Function
@ Function