diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-06-17 15:55:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-17 15:55:14 +0100 |
commit | 9eb0020555fc643582b2802abb8c1bc92059c248 (patch) | |
tree | 3b96308747d3865fdb209f227e2315d7c7d63709 /llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | |
parent | 7ec103a984ff114d24f26d935fe2292379269b53 (diff) | |
download | llvm-9eb0020555fc643582b2802abb8c1bc92059c248.zip llvm-9eb0020555fc643582b2802abb8c1bc92059c248.tar.gz llvm-9eb0020555fc643582b2802abb8c1bc92059c248.tar.bz2 |
[DebugInfo][RemoveDIs] Remove a swathe of debug-intrinsic code (#144389)
Seeing how we can't generate any debug intrinsics any more: delete a
variety of codepaths where they're handled. For the most part these are
plain deletions, in others I've tweaked comments to remain coherent, or
added a type to (what was) type-generic-lambdas.
This isn't all the DbgInfoIntrinsic call sites but it's most of the
simple scenarios.
Co-authored-by: Nikita Popov <github@npopov.com>
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 6b42503..66d0573 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -547,36 +547,22 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // possible or create a clone in the OldPreHeader if not. Instruction *LoopEntryBranch = OrigPreheader->getTerminator(); - // Record all debug intrinsics preceding LoopEntryBranch to avoid + // Record all debug records preceding LoopEntryBranch to avoid // duplication. - using DbgIntrinsicHash = + using DbgHash = std::pair<std::pair<hash_code, DILocalVariable *>, DIExpression *>; - auto makeHash = [](auto *D) -> DbgIntrinsicHash { + auto makeHash = [](const DbgVariableRecord *D) -> DbgHash { auto VarLocOps = D->location_ops(); return {{hash_combine_range(VarLocOps), D->getVariable()}, D->getExpression()}; }; - SmallDenseSet<DbgIntrinsicHash, 8> DbgIntrinsics; - for (Instruction &I : llvm::drop_begin(llvm::reverse(*OrigPreheader))) { - if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) { - DbgIntrinsics.insert(makeHash(DII)); - // Until RemoveDIs supports dbg.declares in DbgVariableRecord format, - // we'll need to collect DbgVariableRecords attached to any other debug - // intrinsics. - for (const DbgVariableRecord &DVR : - filterDbgVars(DII->getDbgRecordRange())) - DbgIntrinsics.insert(makeHash(&DVR)); - } else { - break; - } - } - + SmallDenseSet<DbgHash, 8> DbgRecords; // Build DbgVariableRecord hashes for DbgVariableRecords attached to the - // terminator, which isn't considered in the loop above. + // terminator. for (const DbgVariableRecord &DVR : filterDbgVars(OrigPreheader->getTerminator()->getDbgRecordRange())) - DbgIntrinsics.insert(makeHash(&DVR)); + DbgRecords.insert(makeHash(&DVR)); // Remember the local noalias scope declarations in the header. After the // rotation, they must be duplicated and the scope must be cloned. This @@ -623,7 +609,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // memory (without proving that the loop doesn't write). if (L->hasLoopInvariantOperands(Inst) && !Inst->mayReadFromMemory() && !Inst->mayWriteToMemory() && !Inst->isTerminator() && - !isa<DbgInfoIntrinsic>(Inst) && !isa<AllocaInst>(Inst) && + !isa<AllocaInst>(Inst) && // It is not safe to hoist the value of these instructions in // coroutines, as the addresses of otherwise eligible variables (e.g. // thread-local variables and errno) may change if the coroutine is @@ -642,7 +628,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // Erase anything we've seen before. for (DbgVariableRecord &DVR : make_early_inc_range(filterDbgVars(DbgValueRange))) - if (DbgIntrinsics.count(makeHash(&DVR))) + if (DbgRecords.count(makeHash(&DVR))) DVR.eraseFromParent(); } @@ -671,7 +657,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // Erase anything we've seen before. for (DbgVariableRecord &DVR : make_early_inc_range(filterDbgVars(Range))) - if (DbgIntrinsics.count(makeHash(&DVR))) + if (DbgRecords.count(makeHash(&DVR))) DVR.eraseFromParent(); } @@ -679,13 +665,6 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { RemapInstruction(C, ValueMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); - // Avoid inserting the same intrinsic twice. - if (auto *DII = dyn_cast<DbgVariableIntrinsic>(C)) - if (DbgIntrinsics.count(makeHash(DII))) { - C->eraseFromParent(); - continue; - } - // With the operands remapped, see if the instruction constant folds or is // otherwise simplifyable. This commonly occurs because the entry from PHI // nodes allows icmps and other instructions to fold. @@ -806,7 +785,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { RewriteUsesOfClonedInstructions(OrigHeader, OrigPreheader, ValueMap, SE, &InsertedPHIs); - // Attach dbg.value intrinsics to the new phis if that phi uses a value that + // Attach debug records to the new phis if that phi uses a value that // previously had debug metadata attached. This keeps the debug info // up-to-date in the loop body. if (!InsertedPHIs.empty()) @@ -952,9 +931,6 @@ static bool shouldSpeculateInstrs(BasicBlock::iterator Begin, if (!isSafeToSpeculativelyExecute(&*I)) return false; - if (isa<DbgInfoIntrinsic>(I)) - continue; - switch (I->getOpcode()) { default: return false; |