[LLVMdev] Helping the optimizer along (__assume)

Chris Lattner clattner at apple.com
Thu Oct 23 21:15:38 PDT 2008

On Oct 23, 2008, at 12:23 AM, Duncan Sands wrote:

>>> 	%cond = i1 ...
>>> 	br i1 %cond, label %always, label %never
>>> never:
>>>   call void @llvm.abort()
>>> 	unreachable
>>> At codegen time @llvm.abort() can be lowered to
>>> nothing at all.  I'm not saying that this is my
>>> favorite solution, but it is simple.
>> How is this different than just branching to unreachable?  Branching
>> to unreachable says that "this condition is true or else the program
>> has undefined behavior".  This means that the condition must be  
>> true :)
> The difference is that simplifycfg will remove the branch
> to %never if %never only contains unreachable.  The role
> of the intrinsic call is to fool simplifycfg into not
> doing this!

Sounds like the "bug" is in simplifycfg then.  The IR is already fully  
capable of expressing this without a new builtin.  Note that these  
annotations would have to be removed *sometime* in the optimizer  
pipeline, the policy decision is picking a place.


More information about the llvm-dev mailing list