LLVM 22.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"
18#include <vector>
19
20namespace llvm {
21 class AttrBuilder;
22 class CallBase;
23 class Constant;
24 class Function;
25 class Instruction;
26 class GlobalVariable;
27 class MDNode;
28 class Module;
29 class StringRef;
30 class Type;
31 class Value;
32
33 template <typename T> class OperandBundleDefT;
35
36 /// This is a more granular function that simply checks an intrinsic function
37 /// for upgrading, and returns true if it requires upgrading. It may return
38 /// null in NewFn if the all calls to the original intrinsic function
39 /// should be transformed to non-function-call instructions.
40 LLVM_ABI bool
42 bool CanUpgradeDebugIntrinsicsToRecords = true);
43
44 /// This is the complement to the above, replacing a specific call to an
45 /// intrinsic function with a call to the specified new function.
47
48 // This upgrades the comment for objc retain release markers in inline asm
49 // calls
50 LLVM_ABI void UpgradeInlineAsmString(std::string *AsmStr);
51
52 /// This is an auto-upgrade hook for any old intrinsic function syntaxes
53 /// which need to have both the function updated as well as all calls updated
54 /// to the new function. This should only be run in a post-processing fashion
55 /// so that it can update all calls to the old function.
57
58 /// This checks for global variables which should be upgraded. If it requires
59 /// upgrading, returns a pointer to the upgraded variable.
61
62 /// This checks for module flags which should be upgraded. It returns true if
63 /// module is modified.
65
66 /// Convert legacy nvvm.annotations metadata to appropriate function
67 /// attributes.
69
70 /// Convert calls to ARC runtime functions to intrinsic calls and upgrade the
71 /// old retain release marker to new module flag format.
73
75
76 /// Correct any IR that is relying on old function attribute behavior.
78
79 /// If the given TBAA tag uses the scalar TBAA format, create a new node
80 /// corresponding to the upgrade to the struct-path aware TBAA format.
81 /// Otherwise return the \p TBAANode itself.
83
84 /// This is an auto-upgrade for bitcast between pointers with different
85 /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr.
86 LLVM_ABI Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
87 Instruction *&Temp);
88
89 /// This is an auto-upgrade for bitcast constant expression between pointers
90 /// with different address spaces: the instruction is replaced by a pair
91 /// ptrtoint+inttoptr.
93 Type *DestTy);
94
95 /// Check the debug info version number, if it is out-dated, drop the debug
96 /// info. Return true if module is modified.
98
99 /// Check whether a string looks like an old loop attachment tag.
101 return Name.starts_with("llvm.vectorizer.");
102 }
103
104 /// Upgrade the loop attachment metadata node.
106
107 /// Upgrade the datalayout string by adding a section for address space
108 /// pointers.
109 LLVM_ABI std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple);
110
111 /// Upgrade attributes that changed format or kind.
112 LLVM_ABI void UpgradeAttributes(AttrBuilder &B);
113
114 /// Upgrade operand bundles (without knowing about their user instruction).
115 LLVM_ABI void
116 UpgradeOperandBundles(std::vector<OperandBundleDef> &OperandBundles);
117
118} // End llvm namespace
119
120#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
RelocType Type
Definition: COFFYAML.cpp:410
#define LLVM_ABI
Definition: Compiler.h:213
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1116
This is an important base class in LLVM.
Definition: Constant.h:43
Metadata node.
Definition: Metadata.h:1077
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: InstrTypes.h:1069
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:75
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI 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...
LLVM_ABI void UpgradeSectionAttributes(Module &M)
LLVM_ABI void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
LLVM_ABI bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords=true)
This is a more granular function that simply checks an intrinsic function for upgrading,...
LLVM_ABI MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
LLVM_ABI void UpgradeAttributes(AttrBuilder &B)
Upgrade attributes that changed format or kind.
LLVM_ABI void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
LLVM_ABI void UpgradeNVVMAnnotations(Module &M)
Convert legacy nvvm.annotations metadata to appropriate function attributes.
LLVM_ABI bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
LLVM_ABI void UpgradeOperandBundles(std::vector< OperandBundleDef > &OperandBundles)
Upgrade operand bundles (without knowing about their user instruction).
LLVM_ABI Constant * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
bool mayBeOldLoopAttachmentTag(StringRef Name)
Check whether a string looks like an old loop attachment tag.
Definition: AutoUpgrade.h:100
LLVM_ABI std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
LLVM_ABI GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
LLVM_ABI 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...
LLVM_ABI bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
LLVM_ABI void UpgradeFunctionAttributes(Function &F)
Correct any IR that is relying on old function attribute behavior.
LLVM_ABI MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
LLVM_ABI void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
#define N