indirectbr across function boundaries

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?

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

thanks

regards

Alex

[1] http://llvm.org/docs/LangRef.html#blockaddress
[2] Address of Label and Indirect Branches in LLVM IR - The LLVM Project Blog

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.