If BOLT instrumentation runtime uses XMM registers, it can interfere
with the user program causing crashes and unexpected behavior. This
happens as the instrumentation code preserves general purpose registers
only.
Build BOLT instrumentation runtime with "-mno-sse".
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/D128960
-ffreestanding
-fno-exceptions
-fno-rtti
- -fno-stack-protector)
+ -fno-stack-protector
+ -mno-sse)
# Don't let the compiler think it can create calls to standard libs
target_compile_options(bolt_rt_instr PRIVATE ${BOLT_RT_FLAGS} -fPIE)
--- /dev/null
+#include <stdio.h>
+
+void foo(float a) {
+ printf("a = %f\n", a);
+}
+
+typedef void (*fptr_t)(float);
+fptr_t func = foo;
+
+int main() {
+ func(42);
+ return 0;
+}
+
+/*
+## Check that BOLT instrumentation runtime preserves xmm registers.
+
+REQUIRES: system-linux,bolt-runtime
+
+RUN: %clang %cflags %s -o %t.exe -fno-inline -Wl,-q
+RUN: llvm-bolt %t.exe --instrument -o %t.instrumented
+RUN: %t.instrumented | FileCheck %s
+
+CHECK: a = 42.000000
+*/