diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2024-02-20 16:00:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-20 16:00:55 +0000 |
commit | ababa964752d5bfa6eb608c97f19d4e68df1d243 (patch) | |
tree | 26b6cb86bafab688a348e950479323949092e568 /llvm/lib/IR/BasicBlock.cpp | |
parent | 8f7ae64ea108de54d9aad963c55e1aef7dc62b86 (diff) | |
download | llvm-ababa964752d5bfa6eb608c97f19d4e68df1d243.zip llvm-ababa964752d5bfa6eb608c97f19d4e68df1d243.tar.gz llvm-ababa964752d5bfa6eb608c97f19d4e68df1d243.tar.bz2 |
[RemoveDIs][NFC] Introduce DbgRecord base class [1/3] (#78252)
Patch 1 of 3 to add llvm.dbg.label support to the RemoveDIs project. The
patch stack adds a new base class
-> 1. Add DbgRecord base class for DPValue and the not-yet-added
DPLabel class.
2. Add the DPLabel class.
3. Enable dbg.label conversion and add support to passes.
Patches 1 and 2 are NFC.
In the near future we also will rename DPValue to DbgVariableRecord and
DPLabel to DbgLabelRecord, at which point we'll overhaul the function
names too. The name DPLabel keeps things consistent for now.
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/IR/BasicBlock.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index bf02eba..06807544 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -70,7 +70,7 @@ void BasicBlock::convertToNewDbgValues() { // Iterate over all instructions in the instruction list, collecting dbg.value // instructions and converting them to DPValues. Once we find a "real" // instruction, attach all those DPValues to a DPMarker in that instruction. - SmallVector<DPValue *, 4> DPVals; + SmallVector<DbgRecord *, 4> DPVals; for (Instruction &I : make_early_inc_range(InstList)) { assert(!I.DbgMarker && "DbgMarker already set on old-format instrs?"); if (DbgVariableIntrinsic *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) { @@ -88,7 +88,7 @@ void BasicBlock::convertToNewDbgValues() { createMarker(&I); DPMarker *Marker = I.DbgMarker; - for (DPValue *DPV : DPVals) + for (DbgRecord *DPV : DPVals) Marker->insertDPValue(DPV, false); DPVals.clear(); @@ -107,9 +107,13 @@ void BasicBlock::convertFromNewDbgValues() { continue; DPMarker &Marker = *Inst.DbgMarker; - for (DPValue &DPV : Marker.getDbgValueRange()) - InstList.insert(Inst.getIterator(), - DPV.createDebugIntrinsic(getModule(), nullptr)); + for (DbgRecord &DR : Marker.getDbgValueRange()) { + if (auto *DPV = dyn_cast<DPValue>(&DR)) + InstList.insert(Inst.getIterator(), + DPV->createDebugIntrinsic(getModule(), nullptr)); + else + llvm_unreachable("unsupported DbgRecord kind"); + } Marker.eraseFromParent(); }; @@ -163,9 +167,9 @@ bool BasicBlock::validateDbgValues(bool Assert, bool Msg, raw_ostream *OS) { "Debug Marker points to incorrect instruction?"); // Now validate any DPValues in the marker. - for (DPValue &DPV : CurrentDebugMarker->getDbgValueRange()) { + for (DbgRecord &DPR : CurrentDebugMarker->getDbgValueRange()) { // Validate DebugProgramValues. - TestFailure(DPV.getMarker() == CurrentDebugMarker, + TestFailure(DPR.getMarker() == CurrentDebugMarker, "Not pointing at correct next marker!"); // Verify that no DbgValues appear prior to PHIs. @@ -1086,7 +1090,7 @@ void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First, flushTerminatorDbgValues(); } -void BasicBlock::insertDPValueAfter(DPValue *DPV, Instruction *I) { +void BasicBlock::insertDPValueAfter(DbgRecord *DPV, Instruction *I) { assert(IsNewDbgInfoFormat); assert(I->getParent() == this); @@ -1095,7 +1099,7 @@ void BasicBlock::insertDPValueAfter(DPValue *DPV, Instruction *I) { NextMarker->insertDPValue(DPV, true); } -void BasicBlock::insertDPValueBefore(DPValue *DPV, +void BasicBlock::insertDPValueBefore(DbgRecord *DPV, InstListType::iterator Where) { // We should never directly insert at the end of the block, new DPValues // shouldn't be generated at times when there's no terminator. |