https://llvm.org/bugs/show_bug.cgi?id=27230
Bug ID: 27230
Summary: Naked functions that return values are broken
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Naked functions that return values are compiled incorrectly as soon as
optimizations are turned on. Take the following example:
int foo(void) __attribute__((naked,noinline));
int foo(void) {
// assembly as generated for "return 41;"
asm volatile("mov $41,%%eax; retq" : : : "memory");
}
int main() {
return foo()+1;
}
The program returns the intended value of 42 when compiling with -O0. With -O1
however, the call to foo is replaced with a jump and the program returns 41.
As far as I can tell, the issue is caused by the fact that the end of a naked
functions is "unreachable". This seems to cause optimization passes to make
incorrect assumptions about the behavior of such functions.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs