hiraditya created this revision. hiraditya added a reviewer: rjmccall. Herald added a reviewer: aaron.ballman. hiraditya requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
There are several methods where we do not want function instrumentation which is why we have `__attribute__((no_instrument_function))`. Extending this functionality to disable instrumentation for Objective-C methods as well. Objective C methods like `+load` run premain and having instrumentation on them causes runtime errors depending on the implementation of `__cyg_profile_func_enter` etc. functions Repository: rG LLVM Github Monorepo 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,24 @@ +#import <Foundation/Foundation.h> +// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare -disable-llvm-passes | FileCheck -check-prefix=BARE %s + + +@interface ObjCClass +@end + +@implementation ObjCClass + +// CHECK: @load +// CHECK: "instrument-function-entry"="__cyg_profile_func_enter" ++ (void)load __attribute__((no_instrument_function)) +{ +} + ++ (void)initialize +{ +} + +-(void)dealloc __attribute__((no_instrument_function)) +{ +} +@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; }
Index: clang/test/CodeGen/instrument-objc-method.m =================================================================== --- /dev/null +++ clang/test/CodeGen/instrument-objc-method.m @@ -0,0 +1,24 @@ +#import <Foundation/Foundation.h> +// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare -disable-llvm-passes | FileCheck -check-prefix=BARE %s + + +@interface ObjCClass +@end + +@implementation ObjCClass + +// CHECK: @load +// CHECK: "instrument-function-entry"="__cyg_profile_func_enter" ++ (void)load __attribute__((no_instrument_function)) +{ +} + ++ (void)initialize +{ +} + +-(void)dealloc __attribute__((no_instrument_function)) +{ +} +@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; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits