[PATCH] D28834: Improve what can be promoted in LICM.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 14:47:39 PST 2017

efriedma added inline comments.

Comment at: lib/Transforms/Scalar/LICM.cpp:1028
+    // be assumed not to have previously escaped.
+    if (IsAllocLikeFnRetVal) {
+      if (PointerMayBeCaptured(Object, true, true))
I was thinking of something more like `if (!isa<AllocaInst>()) { if (!isAllocLikeFn()) return false; [...] }`.

Comment at: test/Transforms/LICM/scalar-promote-unwind.ll:211
+  invoke void @boo_with_arg(i32* %0)
+          to label %invoke.cont unwind label %lpad
This doesn't really test what you want it to... it would fail the aliasing test anyway.

Actually, hmm, it's hard to come up with a practical test where the PointerMayBeCaptured check is actually necessary: you need a call which could throw, but provably doesn't access a malloc whose address is captured... our current AA infrastructure can't prove something like that given the way C++ unwinding works.  I guess you could construct an artificial IR testcase with a call that's readnone but not nothrow.


More information about the llvm-commits mailing list