https://bugs.llvm.org/show_bug.cgi?id=41822
Bug ID: 41822
Summary: vfork broken with -fno-builtin
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: eugeni.stepa...@gmail.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
-fno-builtin removes returns_twice attribute from vfork.
Unlike most other attributes, this one is required for correctness.
Missing returns_twice allows the optimizer to use tail calls in the caller of
vfork.
Child process can not use a tail call, because that is effectively a return
from the caller of vfork, and it corrupts the stack of the parent process.
$ cat 1.cc
#include <unistd.h>
__attribute__((optnone, noinline)) static void child() {
volatile bool z = false;
if (!z) _exit(0);
}
void zzztest() {
if (!vfork()) {
child();
}
}
$ bin/clang++ -target armv7-linux 1.cc -O2 -c -fno-builtin && objdump -drl
1.o
_Z7zzztestv():
0: e92d4800 push {fp, lr}
4: e1a0b00d mov fp, sp
8: ebfffffe bl 0 <vfork>
8: R_ARM_CALL vfork
c: e3500000 cmp r0, #0
10: 18bd8800 popne {fp, pc}
14: e8bd4800 pop {fp, lr}
18: eaffffff b 1c <_ZL5childv>
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs