[llvm] r335152 - [Local] Generalize insertReplacementDbgValues, NFC
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 20 11:40:14 PDT 2018
Author: vedantk
Date: Wed Jun 20 11:40:14 2018
New Revision: 335152
URL: http://llvm.org/viewvc/llvm-project?rev=335152&view=rev
Log:
[Local] Generalize insertReplacementDbgValues, NFC
This utility should operate on Values, not Instructions. While I'm here,
I've also made it possible to skip emitting replacement dbg.values for
certain debug users (by having RewriteExpr return nullptr).
Modified:
llvm/trunk/include/llvm/Transforms/Utils/Local.h
llvm/trunk/lib/Transforms/Utils/Local.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=335152&r1=335151&r2=335152&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Wed Jun 20 11:40:14 2018
@@ -334,14 +334,16 @@ void replaceDbgValueForAlloca(AllocaInst
/// 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
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=335152&r1=335151&r2=335152&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Jun 20 11:40:14 2018
@@ -1672,7 +1672,7 @@ void llvm::salvageDebugInfo(Instruction
}
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) {
More information about the llvm-commits
mailing list