[LLVMdev] Indirect branching to BasicBlock

dw dw.dev.mailing at gmail.com
Sun Nov 3 16:36:16 PST 2013


> Check out the generated code for:
>
> --
> #include <stdio.h>
>
> int main(int argc, char **argv) {
>   static void *array[] = { &&foo, &&bar };
>
>   goto *array[argc % 2];
>
> foo:
>   puts("foo");
>   return 0;
>
> bar:
>   puts("bar");
>   return 0;
> }
> --
>
> Also, take a look at the class BlockAddress in llvm/IR/Constants.h.
> I think those might help you out.
>
> H.
>

Thank you! I totally forgot about labels-as-values.



More information about the llvm-dev mailing list