[PATCH] D21612: [compiler-rt] [XRay] Basic initialization and flag definition for XRay runtime

Serge Rogatch via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 05:07:19 PDT 2016


rSerge added a comment.

According to https://www.lri.fr/~filliatr/ens/compil/x86-64.pdf :

> Floating arguments (up to 8) are passed in SSE registers %xmm0, %xmm1, ..., %xmm7. Additional arguments, if


needed, are passed in stack slots. When calling a function that takes a variable number of arguments (notably printf)
or lacks a prototype, byte register %al must be set before the call to indicate how many of the %xmm registers are used.
A floating point return value is returned in %xmm0. All the %xmm registers are caller-save.


================
Comment at: compiler-rt/trunk/lib/xray/xray_trampoline_x86.S:45
@@ +44,3 @@
+	xor	%esi,%esi
+	callq	*%rax
+.Ltmp0:
----------------
I think that if the tracing callback (stored in xray::XRayPatchedFunction ) performs floating-point operations, then the floating-point parameters passed to the instrumented function in SSE registers (%xmm0 to %xmm7) can get corrupted so that the instrumented function gets garbage on input. Shouldn't xray_FunctionEntry push %xmm0...%xmm7 to the stack upon entering and pop them upon exit?

================
Comment at: compiler-rt/trunk/lib/xray/xray_trampoline_x86.S:83
@@ +82,3 @@
+	movl	$1, %esi
+	callq	*%rax
+.Ltmp2:
----------------
The floating-point return value of the instrumented function may be in %xmm0 SSE register. So if xray::XRayPatchedFunction (or its callees) performs floating-point operation, it may clobber the register thus the instrumented function would return garbage. Shouldn't xray_FunctionExit push %xmm0 to the stack on entry and pop it on exit?


Repository:
  rL LLVM

https://reviews.llvm.org/D21612





More information about the llvm-commits mailing list