[LLVMdev] Helping the optimizer along (__assume)

Duncan Sands baldrick at free.fr
Thu Oct 23 00:23:20 PDT 2008


> > 	%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!

Ciao,

Duncan.



More information about the llvm-dev mailing list