[PATCH] D29702: [XRay] Allow logging the first argument of a function call.

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 21:32:03 PST 2017


pelikan updated this revision to Diff 90430.
pelikan marked an inline comment as done.
pelikan added a comment.

- change the number back


https://reviews.llvm.org/D29702

Files:
  include/llvm/CodeGen/AsmPrinter.h
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  test/CodeGen/X86/xray-log-args.ll


Index: test/CodeGen/X86/xray-log-args.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/xray-log-args.ll
@@ -0,0 +1,35 @@
+; When logging arguments is specified, emit the entry sled accordingly.
+
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s
+
+define i32 @callee(i32 %arg) nounwind noinline uwtable "function-instrument"="xray-always" "xray-log-args"="1" {
+  ret i32 %arg
+}
+; CHECK-LABEL: Lxray_synthetic_0:
+; CHECK:	.quad	.Lxray_sled_0
+; CHECK:	.quad	callee
+; CHECK:	.byte	4
+; CHECK:	.byte	1
+; CHECK:	.zero	14
+; CHECK:	.quad	.Lxray_sled_1
+; CHECK:	.quad	callee
+; CHECK:	.byte	1
+; CHECK:	.byte	1
+; CHECK:	.zero	14
+
+define i32 @caller(i32 %arg) nounwind noinline uwtable "function-instrument"="xray-always" "xray-log-args"="1" {
+  %retval = tail call i32 @callee(i32 %arg)
+  ret i32 %retval
+}
+; CHECK-LABEL: Lxray_synthetic_1:
+; CHECK:	.quad	.Lxray_sled_2
+; CHECK:	.quad	caller
+; CHECK:	.byte	4
+; CHECK:	.byte	1
+; CHECK:	.zero	14
+; CHECK:	.quad	.Lxray_sled_3
+; CHECK:	.quad	caller
+; CHECK:	.byte	2
+; CHECK:	.byte	1
+; CHECK:	.zero	14
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2756,8 +2756,11 @@
   SledKind Kind) {
   auto Fn = MI.getParent()->getParent()->getFunction();
   auto Attr = Fn->getFnAttribute("function-instrument");
+  bool LogArgs = Fn->hasFnAttribute("xray-log-args");
   bool AlwaysInstrument =
     Attr.isStringAttribute() && Attr.getValueAsString() == "xray-always";
+  if (Kind == SledKind::FUNCTION_ENTER && LogArgs)
+    Kind = SledKind::LOG_ARGS_ENTER;
   Sleds.emplace_back(
     XRayFunctionEntry{ Sled, CurrentFnSym, Kind, AlwaysInstrument, Fn });
 }
Index: include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- include/llvm/CodeGen/AsmPrinter.h
+++ include/llvm/CodeGen/AsmPrinter.h
@@ -222,6 +222,7 @@
     FUNCTION_ENTER = 0,
     FUNCTION_EXIT = 1,
     TAIL_CALL = 2,
+    LOG_ARGS_ENTER = 3,
   };
 
   // The table will contain these structs that point to the sled, the function


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29702.90430.patch
Type: text/x-patch
Size: 2330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170303/ae2a5b45/attachment.bin>


More information about the llvm-commits mailing list