jump in inline assembly

I have a C program with an inline assembly instruction similar to this:

a = b;
if (foo)
  asm volatile (“jmp *%0” : : “r” (baz)) /* baz points somewhere after etc */

/* here a is used */

When compiled with -O2 clang moves the initialization of a after the if statement and before the first statement of etc, and as consequence the program segfaults when foo == 1. It’s clear that clang presumes that after the asm volatile instruction the execution will fall through the next statement. gcc allows to use the goto keyword after asm [volatile] to inform that an asm block may jump, but this seems not to work in clang. What is the clang equivalent of asm goto? My clang -v: Apple LLVM version 8.0.0 (clang-800.0.38).

Pietro Braione

Clang has no equivalent for GCC asm goto. LLVM does not support jumping between inline asm blobs inside the same function.

Implementing that support is covered by https://llvm.org/bugs/show_bug.cgi?id=9295, which is unlikely to happen.