aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SSAUpdater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/SSAUpdater.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SSAUpdater.cpp28
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());