[PATCH] D111286: Add no_instrument_function attribute to Objective C methods as well

Aditya Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 23:27:17 PDT 2021


hiraditya updated this revision to Diff 377752.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111286/new/

https://reviews.llvm.org/D111286

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/CodeGen/instrument-objc-method.m


Index: clang/test/CodeGen/instrument-objc-method.m
===================================================================
--- /dev/null
+++ clang/test/CodeGen/instrument-objc-method.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare | FileCheck -check-prefix=BARE %s
+
+
+ at interface ObjCClass
+ at end
+
+ at implementation ObjCClass
+
+// CHECK: @"\01+[ObjCClass initialize]"
+// CHECK: call void @__cyg_profile_func_enter
+// CHECK: call void @__cyg_profile_func_exit
+// BARE: @"\01+[ObjCClass initialize]"
+// BARE: call void @__cyg_profile_func_enter
++ (void)initialize
+{
+}
+
+// CHECK: @"\01+[ObjCClass load]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01+[ObjCClass load]"
+// BARE-NOT: call void @__cyg_profile_func_enter
++ (void)load __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: @"\01-[ObjCClass dealloc]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01-[ObjCClass dealloc]"
+// BARE-NOT: call void @__cyg_profile_func_enter
+-(void)dealloc __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: declare void @__cyg_profile_func_enter(i8*, i8*)
+// CHECK: declare void @__cyg_profile_func_exit(i8*, i8*)
+// BARE: declare void @__cyg_profile_func_enter_bare
+ at end
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1979,7 +1979,7 @@
 
 def NoInstrumentFunction : InheritableAttr {
   let Spellings = [GCC<"no_instrument_function">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Documentation = [Undocumented];
   let SimpleHandler = 1;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111286.377752.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211007/165505ae/attachment.bin>


More information about the cfe-commits mailing list