[llvm] r335643 - [Local] Add a convenient insertReplacementDbgValues overload, NFC
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 26 11:44:53 PDT 2018
Author: vedantk
Date: Tue Jun 26 11:44:53 2018
New Revision: 335643
URL: http://llvm.org/viewvc/llvm-project?rev=335643&view=rev
Log:
[Local] Add a convenient insertReplacementDbgValues overload, NFC
Add an overload for the common case where the replacement dbg.values
have the same DIExpressions as the originals.
Modified:
llvm/trunk/include/llvm/Transforms/Utils/Local.h
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
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=335643&r1=335642&r2=335643&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Jun 26 11:44:53 2018
@@ -346,6 +346,11 @@ void insertReplacementDbgValues(
Value &From, Value &To, Instruction &InsertBefore,
function_ref<DIExpression *(DbgInfoIntrinsic &OldDII)> RewriteExpr);
+/// An overload of insertReplacementDbgValues() for the common case where
+/// the replacement dbg.values have the same DIExpressions as the originals.
+void insertReplacementDbgValues(Value &From, Value &To,
+ Instruction &InsertBefore);
+
/// Remove all instructions from a basic block other than it's terminator
/// and any present EH pad instructions.
unsigned removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=335643&r1=335642&r2=335643&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Tue Jun 26 11:44:53 2018
@@ -267,13 +267,9 @@ Instruction *InstCombiner::commonCastTra
// The first cast (CSrc) is eliminable so we need to fix up or replace
// the second cast (CI). CSrc will then have a good chance of being dead.
auto *Res = CastInst::Create(NewOpc, CSrc->getOperand(0), CI.getType());
-
// Replace debug users of the eliminable cast by emitting debug values
// which refer to the new cast.
- insertReplacementDbgValues(
- *CSrc, *Res, *std::next(CI.getIterator()),
- [](DbgInfoIntrinsic &OldDII) { return OldDII.getExpression(); });
-
+ insertReplacementDbgValues(*CSrc, *Res, *std::next(CI.getIterator()));
return Res;
}
}
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=335643&r1=335642&r2=335643&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Jun 26 11:44:53 2018
@@ -1717,9 +1717,19 @@ void llvm::insertReplacementDbgValues(
// that the old debug users will be erased later.
DIBuilder DIB(*InsertBefore.getModule());
for (auto *OldDII : Users)
- if (DIExpression *Expr = RewriteExpr(*OldDII))
- DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(), Expr,
- OldDII->getDebugLoc().get(), &InsertBefore);
+ if (DIExpression *Expr = RewriteExpr(*OldDII)) {
+ auto *I = DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(), Expr,
+ OldDII->getDebugLoc().get(),
+ &InsertBefore);
+ LLVM_DEBUG(dbgs() << "REPLACE: " << *I << '\n');
+ }
+}
+
+void llvm::insertReplacementDbgValues(Value &From, Value &To,
+ Instruction &InsertBefore) {
+ return llvm::insertReplacementDbgValues(
+ From, To, InsertBefore,
+ [](DbgInfoIntrinsic &OldDII) { return OldDII.getExpression(); });
}
unsigned llvm::removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB) {
More information about the llvm-commits
mailing list