[PATCH] D33392: [XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=
Dean Michael Berris via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 22:47:01 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303719: [XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument= (authored by dberris).
Changed prior to commit:
https://reviews.llvm.org/D33392?vs=99715&id=100042#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33392
Files:
cfe/trunk/include/clang/Basic/XRayLists.h
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -1508,6 +1508,10 @@
case ImbueAttr::ALWAYS:
Fn->addFnAttr("function-instrument", "xray-always");
break;
+ case ImbueAttr::ALWAYS_ARG1:
+ Fn->addFnAttr("function-instrument", "xray-always");
+ Fn->addFnAttr("xray-log-args", "1");
+ break;
case ImbueAttr::NEVER:
Fn->addFnAttr("function-instrument", "xray-never");
break;
Index: cfe/trunk/lib/Basic/XRayLists.cpp
===================================================================
--- cfe/trunk/lib/Basic/XRayLists.cpp
+++ cfe/trunk/lib/Basic/XRayLists.cpp
@@ -26,6 +26,8 @@
XRayFunctionFilter::shouldImbueFunction(StringRef FunctionName) const {
// First apply the always instrument list, than if it isn't an "always" see
// whether it's treated as a "never" instrument function.
+ if (AlwaysInstrument->inSection("fun", FunctionName, "arg1"))
+ return ImbueAttribute::ALWAYS_ARG1;
if (AlwaysInstrument->inSection("fun", FunctionName))
return ImbueAttribute::ALWAYS;
if (NeverInstrument->inSection("fun", FunctionName))
Index: cfe/trunk/include/clang/Basic/XRayLists.h
===================================================================
--- cfe/trunk/include/clang/Basic/XRayLists.h
+++ cfe/trunk/include/clang/Basic/XRayLists.h
@@ -37,6 +37,7 @@
NONE,
ALWAYS,
NEVER,
+ ALWAYS_ARG1,
};
ImbueAttribute shouldImbueFunction(StringRef FunctionName) const;
Index: cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp
===================================================================
--- cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp
+++ cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp
@@ -0,0 +1,12 @@
+// RUN: echo "fun:*arg1*=arg1" >> %t.always-instrument
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -fxray-always-instrument=%t.always-instrument -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+void foo() {}
+
+void arg1(void*) {}
+
+// CHECK: define void @_Z3foov() #[[FOO:[0-9]+]] {
+// CHECK: define void {{.*}}arg1{{.*}} #[[ALWAYSARG1:[0-9]+]] {
+
+// CHECK: attributes #[[FOO]] = {{.*}}
+// CHECK: attributes #[[ALWAYSARG1]] = {{.*}} "function-instrument"="xray-always" {{.*}} "xray-log-args"="1"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33392.100042.patch
Type: text/x-patch
Size: 2356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170524/091fc682/attachment.bin>
More information about the cfe-commits
mailing list