LLVM 20.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
19namespace 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 bool CanUpgradeDebugIntrinsicsToRecords = true);
41
42 /// This is the complement to the above, replacing a specific call to an
43 /// intrinsic function with a call to the specified new function.
44 void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn);
45
46 // This upgrades the comment for objc retain release markers in inline asm
47 // calls
48 void UpgradeInlineAsmString(std::string *AsmStr);
49
50 /// This is an auto-upgrade hook for any old intrinsic function syntaxes
51 /// which need to have both the function updated as well as all calls updated
52 /// to the new function. This should only be run in a post-processing fashion
53 /// so that it can update all calls to the old function.
55
56 /// This checks for global variables which should be upgraded. If it requires
57 /// upgrading, returns a pointer to the upgraded variable.
59
60 /// This checks for module flags which should be upgraded. It returns true if
61 /// module is modified.
63
64 /// Convert calls to ARC runtime functions to intrinsic calls and upgrade the
65 /// old retain release marker to new module flag format.
67
69
70 /// Correct any IR that is relying on old function attribute behavior.
72
73 /// If the given TBAA tag uses the scalar TBAA format, create a new node
74 /// corresponding to the upgrade to the struct-path aware TBAA format.
75 /// Otherwise return the \p TBAANode itself.
76 MDNode *UpgradeTBAANode(MDNode &TBAANode);
77
78 /// This is an auto-upgrade for bitcast between pointers with different
79 /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr.
80 Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
81 Instruction *&Temp);
82
83 /// This is an auto-upgrade for bitcast constant expression between pointers
84 /// with different address spaces: the instruction is replaced by a pair
85 /// ptrtoint+inttoptr.
86 Constant *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
87
88 /// Check the debug info version number, if it is out-dated, drop the debug
89 /// info. Return true if module is modified.
90 bool UpgradeDebugInfo(Module &M);
91
92 /// Check whether a string looks like an old loop attachment tag.
94 return Name.starts_with("llvm.vectorizer.");
95 }
96
97 /// Upgrade the loop attachment metadata node.
98 MDNode *upgradeInstructionLoopAttachment(MDNode &N);
99
100 /// Upgrade the datalayout string by adding a section for address space
101 /// pointers.
102 std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple);
103
104 /// Upgrade attributes that changed format or kind.
105 void UpgradeAttributes(AttrBuilder &B);
106
107 /// Upgrade operand bundles (without knowing about their user instruction).
108 void UpgradeOperandBundles(std::vector<OperandBundleDef> &OperandBundles);
109
110} // End llvm namespace
111
112#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
RelocType Type
Definition: COFFYAML.cpp:391
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:1236
This is an important base class in LLVM.
Definition: Constant.h:42
Metadata node.
Definition: Metadata.h:1069
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: InstrTypes.h:1189
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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:74
@ 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
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...
void UpgradeSectionAttributes(Module &M)
void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords=true)
This is a more granular function that simply checks an intrinsic function for upgrading,...
MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
void UpgradeAttributes(AttrBuilder &B)
Upgrade attributes that changed format or kind.
void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
void UpgradeOperandBundles(std::vector< OperandBundleDef > &OperandBundles)
Upgrade operand bundles (without knowing about their user instruction).
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:93
std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
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...
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
void UpgradeFunctionAttributes(Function &F)
Correct any IR that is relying on old function attribute behavior.
MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
#define N