[PATCH] Canonicalize an assume(load != null) into !nonnull metadata

hfinkel at anl.gov hfinkel at anl.gov
Thu Oct 23 23:03:27 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:1113
@@ +1112,3 @@
+      // the same basic block as the Load since that's trivially post
+      // dominated.  We could try to be fancier here, but it's not clear that
+      // doing so is worthwhile.
----------------
It makes me so sad, but this is not correct :(

addr = load
function_that_might_throw()
assume(addr != null)

This has a control dependency on the potentially-throwing function. (Technically, this applies to any function because calling longjmp has the same effect, but LICM only checks mayThrow(), and I see no reason to be more strict anywhere else).

A second, less sad reason why this is not correct is that you need to check the parent of the assume, not the icmp, because they might be in different blocks (and often are after LICM).

In any case, dealing with this "for real" is actually easy: just call
  isValidAssumeForContext(II, LHS, DL, DT)

http://reviews.llvm.org/D5951






More information about the llvm-commits mailing list