[llvm-commits] [llvm] r158937 - in /llvm/trunk: include/llvm/Analysis/MemoryBuiltins.h lib/Analysis/MemoryBuiltins.cpp lib/Transforms/InstCombine/InstCombineCalls.cpp lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine

Duncan Sands baldrick at free.fr
Fri Jun 22 02:14:13 PDT 2012


Hi Nuno,

>> Note that instcombine has "setPreservesCFG" set, which means that it really
>> shouldn't be touching any terminator instructions. It currently does to
>> swap things like "br i1 (xor b, true), label %l1, label %l2" and arguably
>> that doesn't really change the CFG (though I think that in an ideal world
>> instcombine should not be doing that either). This patch certainly does
>> though, and instcombine shouldn't be doing it. You could put it in
>> SimplifyCFG maybe?
>
> Right, just noticed that setPreservesCFG bit as well..
> First I was thinking to create an artificial edge with 'br i1 true,
> normalDest, unwindDest', but LLVM's verifier rejects that.
> This trick is actually used in another place in instcombine, which
> means that the following code crashes instcombine:
>     %call = invoke noalias i8* undef()
>             to label %invoke.cont unwind label %lpad
>
> So now we have 2 places in instcombine that are trying to remove
> invoke instructions..
> A simple solution could be to replace 'invoke @malloc' with 'invoke
> undef', and then move the logic to remove these invokes to
> SimplifyCFG.  What do you think?

if you are changing an invoke into a call, aren't you in essence setting
nounwind on @malloc?  You could just do that and then the invoke will be
dissolved into a call automatically by some other pass.  However, if
that is what you are doing (making malloc as nounwind), shouldn't it be done
in SimplifyLibCalls?

Ciao, Duncan.



More information about the llvm-commits mailing list