diff options
author | Davide Italiano <ditaliano@apple.com> | 2020-06-17 10:29:47 -0700 |
---|---|---|
committer | Davide Italiano <ditaliano@apple.com> | 2020-06-17 11:13:13 -0700 |
commit | 1cbaf847ab84f37d9044d867b5ed8ae646c6ebc9 (patch) | |
tree | 0d7af2a54601057769b7f3dd4e21a2d91f3cf35e /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 7c7c8e0da4e0c400e7e06c4c6658372ea0b487ea (diff) | |
download | llvm-1cbaf847ab84f37d9044d867b5ed8ae646c6ebc9.zip llvm-1cbaf847ab84f37d9044d867b5ed8ae646c6ebc9.tar.gz llvm-1cbaf847ab84f37d9044d867b5ed8ae646c6ebc9.tar.bz2 |
[CGP] Reset the debug location when promoting zext(s).
When the zext gets promoted, it used to retain the original location,
which pessimizes the debugging experience causing an unexpected
jump in stepping at -Og.
Fixes https://bugs.llvm.org/show_bug.cgi?id=46120 (which also
contains a full C repro).
Differential Revision: https://reviews.llvm.org/D81437
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 935fc95..f01a1fe 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -2443,6 +2443,9 @@ namespace { /// This class provides transaction based operation on the IR. /// Every change made through this class is recorded in the internal state and /// can be undone (rollback) until commit is called. +/// CGP does not check if instructions could be speculatively executed when +/// moved. Preserving the original location would pessimize the debugging +/// experience, as well as negatively impact the quality of sample PGO. class TypePromotionTransaction { /// This represents the common interface of the individual transaction. /// Each class implements the logic for doing one specific modification on @@ -2658,6 +2661,7 @@ class TypePromotionTransaction { ZExtBuilder(Instruction *InsertPt, Value *Opnd, Type *Ty) : TypePromotionAction(InsertPt) { IRBuilder<> Builder(InsertPt); + Builder.SetCurrentDebugLocation(DebugLoc()); Val = Builder.CreateZExt(Opnd, Ty, "promoted"); LLVM_DEBUG(dbgs() << "Do: ZExtBuilder: " << *Val << "\n"); } @@ -5798,16 +5802,8 @@ bool CodeGenPrepare::optimizeExt(Instruction *&Inst) { if (canFormExtLd(SpeculativelyMovedExts, LI, ExtFedByLoad, HasPromoted)) { assert(LI && ExtFedByLoad && "Expect a valid load and extension"); TPT.commit(); - // Move the extend into the same block as the load + // Move the extend into the same block as the load. ExtFedByLoad->moveAfter(LI); - // CGP does not check if the zext would be speculatively executed when moved - // to the same basic block as the load. Preserving its original location - // would pessimize the debugging experience, as well as negatively impact - // the quality of sample pgo. We don't want to use "line 0" as that has a - // size cost in the line-table section and logically the zext can be seen as - // part of the load. Therefore we conservatively reuse the same debug - // location for the load and the zext. - ExtFedByLoad->setDebugLoc(LI->getDebugLoc()); ++NumExtsMoved; Inst = ExtFedByLoad; return true; |