Go to the documentation of this file.
28 #define DEBUG_TYPE "bpf-preserve-di-type"
38 static bool BPFPreserveDITypeImpl(
Function &
F) {
39 LLVM_DEBUG(
dbgs() <<
"********** preserve debuginfo type **********\n");
44 if (
M->debug_compile_units().empty())
47 std::vector<CallInst *> PreserveDITypeCalls;
51 auto *
Call = dyn_cast<CallInst>(&
I);
55 const auto *GV = dyn_cast<GlobalValue>(
Call->getCalledOperand());
59 if (GV->getName().startswith(
"llvm.bpf.btf.type.id")) {
60 if (!
Call->getMetadata(LLVMContext::MD_preserve_access_index))
62 "Missing metadata for llvm.bpf.btf.type.id intrinsic");
63 PreserveDITypeCalls.push_back(Call);
68 if (PreserveDITypeCalls.empty())
71 std::string BaseName =
"llvm.btf_type_id.";
73 for (
auto Call : PreserveDITypeCalls) {
81 MDNode *MD =
Call->getMetadata(LLVMContext::MD_preserve_access_index);
88 DIType *Ty = cast<DIType>(MD);
89 while (
auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
90 unsigned Tag = DTy->getTag();
91 if (Tag != dwarf::DW_TAG_const_type &&
92 Tag != dwarf::DW_TAG_volatile_type)
94 Ty = DTy->getBaseType();
98 if (isa<DISubroutineType>(Ty))
100 "SubroutineType not supported for BTF_TYPE_ID_REMOTE reloc");
114 GV->
setMetadata(LLVMContext::MD_preserve_access_index, MD);
121 Call->replaceAllUsesWith(PassThroughInst);
122 Call->eraseFromParent();
143 return new BPFPreserveDIType();
147 return BPFPreserveDITypeImpl(
F);
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
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
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
FunctionPass * createBPFPreserveDIType()
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
This is the shared class of boolean and integer constants.
StringRef getName() const
Class to represent integer types.
void addAttribute(Attribute::AttrKind Kind)
Add attribute to this global.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
static Instruction * insertPassThrough(Module *M, BasicBlock *BB, Instruction *Input, Instruction *Before)
Insert a bpf passthrough builtin function.
INITIALIZE_PASS(BPFPreserveDIType, DEBUG_TYPE, "BPF Preserve Debuginfo Type", false, false) FunctionPass *llvm
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static constexpr StringRef TypeIdAttr
The attribute attached to globals representing a type id.
A Module instance is used to store all the information related to an LLVM module.
StringRef - Represent a constant reference to a string, i.e.
An instruction for reading from memory.
static bool runOnFunction(Function &F, bool PostInlining)
static IntegerType * getInt64Ty(LLVMContext &C)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
@ ExternalLinkage
Externally visible function.
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
std::string to_string(const T &Value)
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
@ BTF_TYPE_ID_LOCAL_RELOC