[llvm-bugs] [Bug 26545] New: x86/x64 clang appears not to respect __attribute__((noinline)) with -O1
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 9 07:12:52 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26545
Bug ID: 26545
Summary: x86/x64 clang appears not to respect
__attribute__((noinline)) with -O1
Product: clang
Version: 3.7
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: llvmbugs at tomseddon.plus.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 15863
--> https://llvm.org/bugs/attachment.cgi?id=15863&action=edit
code
Repro steps:
Compile the attached code with -O1 and generate assembly language.
- From shell: clang -O1 -S main.c (I tested this with Xcode's clang - "Apple
LLVM version 7.0.2 (clang-700.1.81); Target: x86_64-apple-darwin14.5.0; Thread
model: posix")
- See it on gcc explorer: http://goo.gl/Im4c95 (link uses x86 clang 3.7.1)
Expected result:
Generated code contains a call to the Test function somewhere, since Test has
the noinline attribute. (This even though -O1 was specified, and the Test
function is an ideal candidate for inlining.)
Actual result:
The compiler appears to have inlined the Test function (or otherwise determined
somehow that the result of the call would be -55).
Notes:
- I couldn't find any clang documentation for noinline so I'm just making
assumptions about what it does (sorry)
- The gcc documentation for noinline suggests this sort of problem is a
possibility - see
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-g_t_0040code_007bnoinline_007d-function-attribute-3218
- but the workaround it mentions has no effect in clang
- If you force the compiler to generate the Test function (e.g., by adding
something like ``printf("%p\n",(void *)&Test);''), the call still isn't
generated
--
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/20160209/0c3dcfeb/attachment.html>
More information about the llvm-bugs
mailing list