[LLVMbugs] [Bug 22311] New: Clang does not implement the noclone attribute
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jan 23 10:41:49 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22311
Bug ID: 22311
Summary: Clang does not implement the noclone attribute
Product: clang
Version: 3.5
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Driver
Assignee: unassignedclangbugs at nondot.org
Reporter: sstewartgallus00 at mylangara.bc.ca
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
noclone is a companion attribute to the noinline attribute that GCC implements.
It prevents constant propagation from happening. If one is doing magic low
level hackery then it is a necessity. A specific use case I have for this is
creating a safe wrapper for vfork (which most compilers understandably mess up
on).
The wrapper:
__attribute__((noinline))
__attribute__((noclone))
__attribute__((no_sanitize_address))
static pid_t safe_vfork(int (*f)(void *), void * arg)
{
__atomic_signal_fence(__ATOMIC_SEQ_CST);
pid_t child = vfork();
if (0 == child)
_Exit(f(arg));
return child;
}
Some workarounds:
Use assembly: This is annoying but would work.
Put safe_vfork in a separate module: This doesn't work with link-time
optimization but is the typical workaround.
Use volatile on the function arguments as follows: Strangely, this doesn't
actually work. I can further work around this with more indirection but I am
hesitant to do so because the semantics of volatile are very unclear and
compiler specific.
__attribute__((noinline))
__attribute__((noclone))
__attribute__((no_sanitize_address))
static pid_t safe_vfork(int (*volatile f)(void *), void * volatile arg)
{
__atomic_signal_fence(__ATOMIC_SEQ_CST);
pid_t child = vfork();
if (0 == child)
_Exit(f(arg));
return child;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150123/94fa1d76/attachment.html>
More information about the llvm-bugs
mailing list