Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add no_instrument_function attribute to Objective C methods as well
There are functions 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 Reviewed By: rjmccall, aaron.ballman Differential Revision: https://reviews.llvm.org/D111286
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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 | ||
|
||
@interface ObjCClass | ||
@end | ||
|
||
@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 | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s | ||
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s | ||
|
||
// expected-no-diagnostics | ||
@interface A | ||
+ (void)F __attribute__((no_instrument_function)); // no warning | ||
- (void)f __attribute__((objc_direct, no_instrument_function)); | ||
- (void)g; | ||
@end | ||
|
||
@implementation A | ||
+ (void)F __attribute__((no_instrument_function)) { | ||
[self F]; | ||
} | ||
|
||
- (void)f { | ||
[self g]; | ||
} | ||
|
||
- (void)g { | ||
} | ||
@end |