[PATCH] D84802: Add control over debug lines dropping
Jacek Galazka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 14:35:38 PDT 2020
jacek-galazka created this revision.
jacek-galazka added a reviewer: echristo.
Herald added subscribers: llvm-commits, asbirlea, hiraditya.
Herald added a project: LLVM.
jacek-galazka requested review of this revision.
Control if GVN and LICM pass should retain debug locations of moved instructions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84802
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -134,6 +134,10 @@
"number of accesses allowed to be present in a loop in order to "
"enable memory promotion."));
+cl::opt<bool> AllowJumpyDebugTables(
+ "allow-jumpy-debug-lines-tables", cl::Hidden, cl::init(false),
+ cl::desc("Retain debug locations of instructions moved by eg. LICM."));
+
static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI);
static bool isNotUsedOrFreeInLoop(const Instruction &I, const Loop *CurLoop,
const LoopSafetyInfo *SafetyInfo,
@@ -1659,9 +1663,10 @@
moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo, MSSAU, SE);
// Apply line 0 debug locations when we are moving instructions to different
- // basic blocks because we want to avoid jumpy line tables.
+ // basic blocks if we want to avoid jumpy line tables.
if (const DebugLoc &DL = I.getDebugLoc())
- I.setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
+ if (!AllowJumpyDebugTables)
+ I.setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
if (isa<LoadInst>(I))
++NumMovedLoads;
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -122,6 +122,8 @@
"into) when deducing if a value is fully avaliable or not in GVN "
"(default = 600)"));
+extern cl::opt<bool> AllowJumpyDebugTables;
+
struct llvm::GVN::Expression {
uint32_t opcode;
bool commutative = false;
@@ -1312,10 +1314,12 @@
// Assign value numbers to the new instructions.
for (Instruction *I : NewInsts) {
// Instructions that have been inserted in predecessor(s) to materialize
- // the load address do not retain their original debug locations. Doing
- // so could lead to confusing (but correct) source attributions.
+ // the load address can retain their original debug locations. Doing
+ // so leads to confusing source attributions. However as locations are
+ // correct, they can be useful.
if (const DebugLoc &DL = I->getDebugLoc())
- I->setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
+ if (!AllowJumpyDebugTables)
+ I->setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
// FIXME: We really _ought_ to insert these value numbers into their
// parent's availability map. However, in doing so, we risk getting into
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84802.281365.patch
Type: text/x-patch
Size: 2698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/9af8ac2e/attachment.bin>
More information about the llvm-commits
mailing list