diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/XRayLists.h | 1 | ||||
-rw-r--r-- | clang/lib/Basic/XRayLists.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 | ||||
-rw-r--r-- | clang/test/CodeGen/xray-imbue-arg1.cpp | 12 |
4 files changed, 19 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/XRayLists.h b/clang/include/clang/Basic/XRayLists.h index fe538289c3a..8cfea70e280 100644 --- a/clang/include/clang/Basic/XRayLists.h +++ b/clang/include/clang/Basic/XRayLists.h @@ -37,6 +37,7 @@ public: NONE, ALWAYS, NEVER, + ALWAYS_ARG1, }; ImbueAttribute shouldImbueFunction(StringRef FunctionName) const; diff --git a/clang/lib/Basic/XRayLists.cpp b/clang/lib/Basic/XRayLists.cpp index dccf3baa75e..0a439c7af90 100644 --- a/clang/lib/Basic/XRayLists.cpp +++ b/clang/lib/Basic/XRayLists.cpp @@ -26,6 +26,8 @@ XRayFunctionFilter::ImbueAttribute 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)) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9d0f802ece0..db8f8d32abb 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1508,6 +1508,10 @@ bool CodeGenModule::imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc, 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; diff --git a/clang/test/CodeGen/xray-imbue-arg1.cpp b/clang/test/CodeGen/xray-imbue-arg1.cpp new file mode 100644 index 00000000000..eb272b97eaf --- /dev/null +++ b/clang/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" |