[PATCH] D20944: LICM: Don't sink stores out of loops that may throw.

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 04:17:09 PDT 2016


hfinkel accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: lib/Transforms/Scalar/LICM.cpp:936
@@ +935,3 @@
+    // Currently, this code just special-cases alloca instructions.
+    if (!isa<AllocaInst>(GetUnderlyingObject(SomePtr, MDL)))
+      return false;
----------------
eli.friedman wrote:
> eli.friedman wrote:
> > hfinkel wrote:
> > > The assumption here is that stores to allocas much be unobservable after the function unwinds, and I agree with that. However, what if the exception is caught in this function. In that case, such a store might still be observable.
> > > 
> > > Also, it would be friendlier to call GetUnderlyingObjects and check whether any are not allocas (if we can determine that there are no relevant landingpads?).
> > > 
> > The tricky case here is specifically call instructions, which unwind without an explicit unwind edge . If there's an invoke instruction in a loop, the unwind edge is visible to the optimizer; we can treat it the same way as any other loop exit.
> > 
> > Changing this to use GetUnderlyingObjects seems fine.
> Hmm... actually, just tried GetUnderlyingObjects; can't get it to do anything useful because alias analysis can't figure out that `x ? &a2 : &a2` doesn't alias an arbitrary function call.
Okay, we should fix that too :( - This LGTM.


http://reviews.llvm.org/D20944





More information about the llvm-commits mailing list