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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 00:01:39 PDT 2016


eli.friedman added inline comments.

================
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:
> 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.


http://reviews.llvm.org/D20944





More information about the llvm-commits mailing list