Skip to content

LLVM 13 Regression: __builtin_longjmp not working with -Oz #51071

@xtkoba

Description

@xtkoba
mannequin
Bugzilla Link 51729
Version trunk
OS Linux
Blocks #50580 #51489
Attachments Repro, Repro (with workaround added), bsjlj.ll diff with D109248 applied
CC @aeubanks,@DimitryAndric,@RKSimon,@tstellar

Extended Description

Tested with 13.0.0-rc2 and 12.0.1. The repro could be made shorter.

Note that this issue is not necessarily specific to X86_64. A segfault is also observed for ARM.

$ cat bsjlj.c
void foo(void **jb, int n); void bar(int n); void bsj(void **jb, volatile int n) { if (__builtin_setjmp(jb) == 0) { foo(jb, n); } else { bar(n); } } void blj(void **jb) { __builtin_longjmp(jb, 1); } int printf (const char *__restrict __format, ...); void foo(void **jb, int n) { printf("foo: n = %d\n", n); blj(jb); } void bar(int n) { printf("bar: n = %d\n", n); } int main(int argc, char *argv[] __attribute__((unused))) { void *jb[5]; bsj(jb, argc); bsj(jb, argc+1); return 0; }
$ /usr/lib/llvm/12/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall -Wextra -Wundef $ ./a.out foo: n = 1 bar: n = 1 foo: n = 2 bar: n = 2 $ /usr/lib/llvm/13/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall -Wextra -Wundef $ ./a.out foo: n = 1 bar: n = 32764 Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvmUmbrella label for LLVM issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions