[LLVMdev] indirectbr across function boundaries

Dale Johannesen dalej at apple.com
Wed Sep 15 10:47:35 PDT 2010


On Sep 15, 2010, at 10:17 AMPDT, Alexander Bernauer wrote:

> Hi
> 
> according to [1] and [2] the blockaddress of any basic block can be
> obtained.
> 
> But I am not sure about that fact that an indirectbr can only target at
> a basic block which is within the same function as the indirectbr instruction.
> 
> [1] states:
> ---8<---
> All possible destination blocks must be listed in the label list,
> otherwise this instruction has undefined behavior. This implies that
> jumps to labels defined in other functions have undefined behavior as
> well.
> --->8---
> 
> I don't understand this implication. And what exactly is meant by "other
> functions"? Can anybody clearify this?

All functions except the one containing the ibr

> I just want to make sure cross-function branches are really impossible.

Depends what you mean by impossible.  You can of course create a .ll file that violates this restriction.  But this is not a valid LLVM IR file, and will be rejected by verification checking.

If you're trying to do something that works on valid LLVM IR, you don't have to consider this case, if that's what you mean.

> thanks
> 
> regards
> 
> Alex
> 
> [1] http://llvm.org/docs/LangRef.html#blockaddress
> [2] http://blog.llvm.org/2010/01/address-of-label-and-indirect-branches.html
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list