[LLVMbugs] [Bug 19317] New: [ARM] instrumentation code injection has user visible side-effects
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Apr 2 19:31:52 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19317
Bug ID: 19317
Summary: [ARM] instrumentation code injection has user visible
side-effects
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: ARM
Assignee: unassignedbugs at nondot.org
Reporter: compnerd at compnerd.org
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
When compiling with -pg, the instrumentation code injection appears to cause
user-visible side-effects. This, in particular, breaks compiling Linux via
clang.
Consider the following minimal test case:
// RUN: %clang_cc1 -triple=armv7-linux -S %s -o - | FileCheck %s
void function(int i) {
__asm__ __volatile__ (".ifnc %0, r0 ; .error \"ABI mismatch\" ; .endif" : :
"r"(i));
}
This translates to:
define void arm_aapcscc @function(i32 %i) {
entry:
tail call void asm sideeffect ".ifnc $0, r0 ; .error \22ABI mismatch\22 ;
.endif", "r"(i32 %i)
ret void
}
Awesome: argument i is being passed along to the function, which is going to be
in register r0 as per the AAPCS CC.
However, compiling this with profiling (-pg) does a slightly different thing
which is mostly correct:
declare void @mcount()
define void arm_aapcscc @function(i32 %i) {
entry:
tail call void @mcount()
tail call void asm sideeffect ".ifnc $0, r0 ; .error \22ABI mismatch\22 ;
.endif", "r"(i32 %i)
ret void
}
This looks reasonable: the inserted mcount is what you would expect due to the
profiling. And the argument is still passed along.
However, when target lowering: you end up with the following:
push {r4, r11, lr}
add r11, sp, #4
mov r4, r0
bl mcount
@APP
.ifnc r4, r0 ; .error "ABI mismatch" ; endif
@NO_APP
pop {r4, r11, pc}
So, we adjust the stack, save the parameters (since we have no idea what mcount
will do) and call mcount. Now, we use the saved register (r4 is callee saved,
so we know it has the right value at this point) and pass it along to the side
effect (inline asm). This is now visible to the user.
--
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/20140403/c9aca5d6/attachment.html>
More information about the llvm-bugs
mailing list