[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

Nick Lewycky nicholas at mxc.ca
Fri Jun 22 03:16:01 PDT 2012


Nuno Lopes wrote:
> Quoting Nick Lewycky<nlewycky at google.com>:
>
>> On 21 June 2012 14:25, Nuno Lopes<nunoplopes at sapo.pt>  wrote:
>>
>>> Author: nlopes
>>> Date: Thu Jun 21 16:25:05 2012
>>> New Revision: 158937
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=158937&view=rev
>>> Log:
>>> Add support for invoke to the MemoryBuiltin analysid.
>>> Update comments accordingly.
>>>
>>> Make instcombine remove useless invokes to C++'s 'new' allocation function
>>> (test attached).
>>>
>>
>> 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?

I don't think instcombine should touch invokes at all. If there's an 
invoke to a function marked nounwind then simplifycfg should replace the 
invoke with a call. Calls to malloc etc. that can't throw should be 
marked nounwind by the simplify-libcalls pass.

Nick



More information about the llvm-commits mailing list