diff options
author | Carlos Alberto Enciso <carlos.alberto.enciso@gmail.com> | 2023-06-30 06:09:44 +0100 |
---|---|---|
committer | Carlos Alberto Enciso <carlos.alberto.enciso@gmail.com> | 2023-06-30 06:24:56 +0100 |
commit | 8763d79949975c7d2384c0311c66fa8e4a327c45 (patch) | |
tree | b70f9380f36695711ecc7ac4129d726f25e2a7de /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | a9256a2e0450019aeb2dfcc3ad9fefb23d6d6f83 (diff) | |
download | llvm-8763d79949975c7d2384c0311c66fa8e4a327c45.zip llvm-8763d79949975c7d2384c0311c66fa8e4a327c45.tar.gz llvm-8763d79949975c7d2384c0311c66fa8e4a327c45.tar.bz2 |
[loop-deletion] Overly defensive with undef-ing dbg.values.
Explicitly inserting undef is overly defensive. Any values computed
nside the loop that are referenced by dbg.values should naturally
become undef when the loop is deleted, and all other values that
are loop invariant must be preserved.
Reviewed By: scott.linder
Differential Revision: https://reviews.llvm.org/D153539
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 2dfaea7..7d6662c 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -641,18 +641,17 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, } // After the loop has been deleted all the values defined and modified - // inside the loop are going to be unavailable. - // Since debug values in the loop have been deleted, inserting an undef - // dbg.value truncates the range of any dbg.value before the loop where the - // loop used to be. This is particularly important for constant values. + // inside the loop are going to be unavailable. Values computed in the + // loop will have been deleted, automatically causing their debug uses + // be be replaced with undef. Loop invariant values will still be available. + // Move dbg.values out the loop so that earlier location ranges are still + // terminated and loop invariant assignments are preserved. Instruction *InsertDbgValueBefore = ExitBlock->getFirstNonPHI(); assert(InsertDbgValueBefore && "There should be a non-PHI instruction in exit block, else these " "instructions will have no parent."); - for (auto *DVI : DeadDebugInst) { - DVI->setKillLocation(); + for (auto *DVI : DeadDebugInst) DVI->moveBefore(InsertDbgValueBefore); - } } // Remove the block from the reference counting scheme, so that we can |