diff options
author | Marco Elver <elver@google.com> | 2022-09-06 15:48:41 +0200 |
---|---|---|
committer | Marco Elver <elver@google.com> | 2022-09-06 15:52:44 +0200 |
commit | 42836e283fc58d5cebbcbb2e8eb7619d92fb9c2d (patch) | |
tree | 11548affdf88abaec2dabced3769d71681e86751 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | c70f6e1362e38f36dceca0342490d659aa45a1a5 (diff) | |
download | llvm-42836e283fc58d5cebbcbb2e8eb7619d92fb9c2d.zip llvm-42836e283fc58d5cebbcbb2e8eb7619d92fb9c2d.tar.gz llvm-42836e283fc58d5cebbcbb2e8eb7619d92fb9c2d.tar.bz2 |
[MachineInstr] Allow setting PCSections in ExtraInfo
Provide MachineInstr::setPCSection(), to propagate relevant metadata
through the backend. Use ExtraInfo to store the metadata.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D130876
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 08437ff..18d11e6b 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -301,13 +301,15 @@ void MachineInstr::setExtraInfo(MachineFunction &MF, ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol, MCSymbol *PostInstrSymbol, - MDNode *HeapAllocMarker, uint32_t CFIType) { + MDNode *HeapAllocMarker, MDNode *PCSections, + uint32_t CFIType) { bool HasPreInstrSymbol = PreInstrSymbol != nullptr; bool HasPostInstrSymbol = PostInstrSymbol != nullptr; bool HasHeapAllocMarker = HeapAllocMarker != nullptr; + bool HasPCSections = PCSections != nullptr; bool HasCFIType = CFIType != 0; int NumPointers = MMOs.size() + HasPreInstrSymbol + HasPostInstrSymbol + - HasHeapAllocMarker + HasCFIType; + HasHeapAllocMarker + HasPCSections + HasCFIType; // Drop all extra info if there is none. if (NumPointers <= 0) { @@ -319,9 +321,11 @@ void MachineInstr::setExtraInfo(MachineFunction &MF, // out of line because PointerSumType cannot hold more than 4 tag types with // 32-bit pointers. // FIXME: Maybe we should make the symbols in the extra info mutable? - else if (NumPointers > 1 || HasHeapAllocMarker || HasCFIType) { - Info.set<EIIK_OutOfLine>(MF.createMIExtraInfo( - MMOs, PreInstrSymbol, PostInstrSymbol, HeapAllocMarker, CFIType)); + else if (NumPointers > 1 || HasHeapAllocMarker || HasPCSections || + HasCFIType) { + Info.set<EIIK_OutOfLine>( + MF.createMIExtraInfo(MMOs, PreInstrSymbol, PostInstrSymbol, + HeapAllocMarker, PCSections, CFIType)); return; } @@ -339,7 +343,7 @@ void MachineInstr::dropMemRefs(MachineFunction &MF) { return; setExtraInfo(MF, {}, getPreInstrSymbol(), getPostInstrSymbol(), - getHeapAllocMarker(), getCFIType()); + getHeapAllocMarker(), getPCSections(), getCFIType()); } void MachineInstr::setMemRefs(MachineFunction &MF, @@ -350,7 +354,7 @@ void MachineInstr::setMemRefs(MachineFunction &MF, } setExtraInfo(MF, MMOs, getPreInstrSymbol(), getPostInstrSymbol(), - getHeapAllocMarker(), getCFIType()); + getHeapAllocMarker(), getPCSections(), getCFIType()); } void MachineInstr::addMemOperand(MachineFunction &MF, @@ -373,7 +377,8 @@ void MachineInstr::cloneMemRefs(MachineFunction &MF, const MachineInstr &MI) { // are the same (including null). if (getPreInstrSymbol() == MI.getPreInstrSymbol() && getPostInstrSymbol() == MI.getPostInstrSymbol() && - getHeapAllocMarker() == MI.getHeapAllocMarker()) { + getHeapAllocMarker() == MI.getHeapAllocMarker() && + getPCSections() == MI.getPCSections()) { Info = MI.Info; return; } @@ -458,7 +463,7 @@ void MachineInstr::setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol) { } setExtraInfo(MF, memoperands(), Symbol, getPostInstrSymbol(), - getHeapAllocMarker(), getCFIType()); + getHeapAllocMarker(), getPCSections(), getCFIType()); } void MachineInstr::setPostInstrSymbol(MachineFunction &MF, MCSymbol *Symbol) { @@ -473,7 +478,7 @@ void MachineInstr::setPostInstrSymbol(MachineFunction &MF, MCSymbol *Symbol) { } setExtraInfo(MF, memoperands(), getPreInstrSymbol(), Symbol, - getHeapAllocMarker(), getCFIType()); + getHeapAllocMarker(), getPCSections(), getCFIType()); } void MachineInstr::setHeapAllocMarker(MachineFunction &MF, MDNode *Marker) { @@ -482,7 +487,16 @@ void MachineInstr::setHeapAllocMarker(MachineFunction &MF, MDNode *Marker) { return; setExtraInfo(MF, memoperands(), getPreInstrSymbol(), getPostInstrSymbol(), - Marker, getCFIType()); + Marker, getPCSections(), getCFIType()); +} + +void MachineInstr::setPCSections(MachineFunction &MF, MDNode *PCSections) { + // Do nothing if old and new symbols are the same. + if (PCSections == getPCSections()) + return; + + setExtraInfo(MF, memoperands(), getPreInstrSymbol(), getPostInstrSymbol(), + getHeapAllocMarker(), PCSections, getCFIType()); } void MachineInstr::setCFIType(MachineFunction &MF, uint32_t Type) { @@ -491,7 +505,7 @@ void MachineInstr::setCFIType(MachineFunction &MF, uint32_t Type) { return; setExtraInfo(MF, memoperands(), getPreInstrSymbol(), getPostInstrSymbol(), - getHeapAllocMarker(), Type); + getHeapAllocMarker(), getPCSections(), Type); } void MachineInstr::cloneInstrSymbols(MachineFunction &MF, @@ -506,6 +520,7 @@ void MachineInstr::cloneInstrSymbols(MachineFunction &MF, setPreInstrSymbol(MF, MI.getPreInstrSymbol()); setPostInstrSymbol(MF, MI.getPostInstrSymbol()); setHeapAllocMarker(MF, MI.getHeapAllocMarker()); + setPCSections(MF, MI.getPCSections()); } uint16_t MachineInstr::mergeFlagsWith(const MachineInstr &Other) const { @@ -1767,6 +1782,14 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << " heap-alloc-marker "; HeapAllocMarker->printAsOperand(OS, MST); } + if (MDNode *PCSections = getPCSections()) { + if (!FirstOp) { + FirstOp = false; + OS << ','; + } + OS << " pcsections "; + PCSections->printAsOperand(OS, MST); + } if (uint32_t CFIType = getCFIType()) { if (!FirstOp) OS << ','; |