[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

Nuno Lopes nunoplopes at sapo.pt
Thu Jun 21 16:28:50 PDT 2012


Quoting Nuno Lopes <nunoplopes at sapo.pt>:

> 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?

Ok, so I spoke with Eli, and this solution almost works, but not  
quite. Almost because 'invoke undef' is, well, undefined behavior, and  
therefore we don't really want to do it.
We could have, however, a No-op intrinsic (llvm.noop), and invoke it  
instead. Then simplify cfg could remove those invokes.  I was just  
trying to remember if there's any intrinsic that we could reuse with  
the right parameters to make it a NOOP..

Nuno



More information about the llvm-commits mailing list