[PATCH] D128960: [BOLT] Fix instrumentation problem with floating point
Maksim Panchenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 18:57:51 PDT 2022
maksfb created this revision.
maksfb added reviewers: yota9, Amir, ayermolo, rafauler, zr33, nhuhuan, FPar.
Herald added a subscriber: mgorny.
Herald added a project: All.
maksfb requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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".
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128960
Files:
bolt/runtime/CMakeLists.txt
bolt/test/runtime/X86/instrumentation-xmm.c
Index: bolt/test/runtime/X86/instrumentation-xmm.c
===================================================================
--- /dev/null
+++ bolt/test/runtime/X86/instrumentation-xmm.c
@@ -0,0 +1,25 @@
+#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
+*/
Index: bolt/runtime/CMakeLists.txt
===================================================================
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -23,7 +23,8 @@
-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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128960.441573.patch
Type: text/x-patch
Size: 1096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220701/0ba529e1/attachment.bin>
More information about the llvm-commits
mailing list