[PATCH] D107016: [DebugInfo][LoopStrengthReduction] Ensure restoration of cached DIExpression when using SCEV-based salvaging

Chris Jackson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 17:31:31 PDT 2021


chrisjackson created this revision.
chrisjackson added reviewers: jmorse, djtodoro, StephenTozer, Orlando, aprantl, dblaikie, markus, TWeaver.
chrisjackson added a project: debug-info.
Herald added subscribers: javed.absar, hiraditya.
chrisjackson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently only those dbg.value that have are modified from single location-op to multi location-op by LSR have their DIExpression restored when using SCEV-based salvaging. This patch ensures that dbg.value have their cached DIExpressions restored regardless of the number of location ops. I believe this DIExpression restoration was present in Markus' original LSR salvaging method.


https://reviews.llvm.org/D107016

Files:
  llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6178,15 +6178,17 @@
       // Some DVIs that were single location-op when cached are now multi-op,
       // due to LSR optimisations. However, multi-op salvaging is not yet
       // supported by SCEV salvaging. But, we can attempt a salvage by restoring
-      // the pre-LSR single-op expression.
+      // the pre-LSR single-op location and expression.
       if (DVIRec.DVI->hasArgList()) {
         if (!DVIRec.DVI->getVariableLocationOp(0))
           continue;
         llvm::Type *Ty = DVIRec.DVI->getVariableLocationOp(0)->getType();
         DVIRec.DVI->setRawLocation(
             llvm::ValueAsMetadata::get(UndefValue::get(Ty)));
-        DVIRec.DVI->setExpression(DVIRec.Expr);
       }
+      // LSR may have updated the expression, so restore to the expression
+      // that corresponds to te cached SCEV.
+      DVIRec.DVI->setExpression(DVIRec.Expr);
 
       Changed |= RewriteDVIUsingIterCount(DVIRec, IterCountExpr, SE);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107016.362588.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/e9737705/attachment.bin>


More information about the llvm-commits mailing list