[llvm] [BPF] Remove 'may_goto 0' instructions (PR #123482)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 12:53:03 PST 2025


eddyz87 wrote:

And the following example appears to miscompiled:

```c
$ cat test.c
void bar() {
  asm volatile goto ("may_goto %l[lbl];"::::lbl);
  asm volatile goto ("may_goto %l[lbl];"::::lbl);
  asm volatile goto ("may_goto %l[lbl];"::::lbl);
  asm volatile goto ("r0 = 42;");
 lbl:
  return;
}
{llvm} 12:45:19 tmp$ clang -O2 --target=bpf -S test.c -o - 2>&1 | head -n20
	.file	"test.c"
	.text
	.globl	bar                             # -- Begin function bar
	.p2align	3
	.type	bar, at function
bar:                                    # @bar
# %bb.0:                                # %entry
	#APP
	may_goto LBB0_4

	#NO_APP
# %bb.1:                                # %asm.fallthrough
	#APP
	may_goto LBB0_4

	#NO_APP
# %bb.2:                                # %asm.fallthrough1
	#APP
	may_goto LBB0_4
```

(Note the disappearance of the `"r0 = 42;"`).

https://github.com/llvm/llvm-project/pull/123482


More information about the llvm-commits mailing list