summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Transforms/Utils/Local.h8
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp10
2 files changed, 10 insertions, 8 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/Local.h b/llvm/include/llvm/Transforms/Utils/Local.h
index f09ebe5e247..5290651324d 100644
--- a/llvm/include/llvm/Transforms/Utils/Local.h
+++ b/llvm/include/llvm/Transforms/Utils/Local.h
@@ -334,14 +334,16 @@ void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
/// DIExpression.
void salvageDebugInfo(Instruction &I);
-/// Assuming the instruction \p From is going to be deleted, insert replacement
+/// Assuming the value \p From is going to be deleted, insert replacement
/// dbg.value intrinsics for each debug user of \p From. The newly-inserted
/// dbg.values refer to \p To instead of \p From. Each replacement dbg.value
/// has the same location and variable as the debug user it replaces, has a
/// DIExpression determined by the result of \p RewriteExpr applied to an old
-/// debug user of \p From, and is placed before \p InsertBefore.
+/// debug user of \p From, and is placed before \p InsertBefore. If
+/// \p RewriteExpr returns nullptr, no replacement for the specified debug
+/// user is emitted.
void insertReplacementDbgValues(
- Instruction &From, Instruction &To, Instruction &InsertBefore,
+ Value &From, Value &To, Instruction &InsertBefore,
function_ref<DIExpression *(DbgInfoIntrinsic &OldDII)> RewriteExpr);
/// Remove all instructions from a basic block other than it's terminator
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 7dd74a1aa40..a718276b222 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1672,7 +1672,7 @@ void llvm::salvageDebugInfo(Instruction &I) {
}
void llvm::insertReplacementDbgValues(
- Instruction &From, Instruction &To, Instruction &InsertBefore,
+ Value &From, Value &To, Instruction &InsertBefore,
function_ref<DIExpression *(DbgInfoIntrinsic &OldDII)> RewriteExpr) {
// Collect all debug users of From.
SmallVector<DbgInfoIntrinsic *, 1> Users;
@@ -1682,11 +1682,11 @@ void llvm::insertReplacementDbgValues(
// Insert a replacement debug value for each old debug user. It's assumed
// that the old debug users will be erased later.
- DIBuilder DIB(*From.getModule());
+ DIBuilder DIB(*InsertBefore.getModule());
for (auto *OldDII : Users)
- DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(),
- RewriteExpr(*OldDII),
- OldDII->getDebugLoc().get(), &InsertBefore);
+ if (DIExpression *Expr = RewriteExpr(*OldDII))
+ DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(), Expr,
+ OldDII->getDebugLoc().get(), &InsertBefore);
}
unsigned llvm::removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB) {
OpenPOWER on IntegriCloud