diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:03:47 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:04:23 +0000 |
| commit | 7fa27ce4a07f19b07799a767fc29416f3b625afb (patch) | |
| tree | 27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/Transforms/Utils/SSAUpdater.cpp | |
| parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) | |
Diffstat (limited to 'llvm/lib/Transforms/Utils/SSAUpdater.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SSAUpdater.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp index 2520aa5d9db0..ebe9cb27f5ab 100644 --- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp +++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp @@ -19,6 +19,7 @@ #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" @@ -195,6 +196,33 @@ void SSAUpdater::RewriteUse(Use &U) { U.set(V); } +void SSAUpdater::UpdateDebugValues(Instruction *I) { + SmallVector<DbgValueInst *, 4> DbgValues; + llvm::findDbgValues(DbgValues, I); + for (auto &DbgValue : DbgValues) { + if (DbgValue->getParent() == I->getParent()) + continue; + UpdateDebugValue(I, DbgValue); + } +} + +void SSAUpdater::UpdateDebugValues(Instruction *I, + SmallVectorImpl<DbgValueInst *> &DbgValues) { + for (auto &DbgValue : DbgValues) { + UpdateDebugValue(I, DbgValue); + } +} + +void SSAUpdater::UpdateDebugValue(Instruction *I, DbgValueInst *DbgValue) { + BasicBlock *UserBB = DbgValue->getParent(); + if (HasValueForBlock(UserBB)) { + Value *NewVal = GetValueAtEndOfBlock(UserBB); + DbgValue->replaceVariableLocationOp(I, NewVal); + } + else + DbgValue->setKillLocation(); +} + void SSAUpdater::RewriteUseAfterInsertions(Use &U) { Instruction *User = cast<Instruction>(U.getUser()); |
