From 5ec8fe19cf10d64f17ba24e066c7450ee95abecb Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Thu, 6 Mar 2014 06:10:02 +0000 Subject: PGO: add instrumentation for Objective-C methods. llvm-svn: 203085 --- .../test/CodeGenObjC/Inputs/instr-profile.profdata | 2 +- clang/test/CodeGenObjC/instr-profile.m | 32 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'clang/test/CodeGenObjC') diff --git a/clang/test/CodeGenObjC/Inputs/instr-profile.profdata b/clang/test/CodeGenObjC/Inputs/instr-profile.profdata index f3c03cc7930..f068640dbca 100644 --- a/clang/test/CodeGenObjC/Inputs/instr-profile.profdata +++ b/clang/test/CodeGenObjC/Inputs/instr-profile.profdata @@ -1,4 +1,4 @@ -foreach 2 +instr-profile.m:+[A foreach:] 2 1 2 diff --git a/clang/test/CodeGenObjC/instr-profile.m b/clang/test/CodeGenObjC/instr-profile.m index e1b13edf215..f232d985d83 100644 --- a/clang/test/CodeGenObjC/instr-profile.m +++ b/clang/test/CodeGenObjC/instr-profile.m @@ -8,11 +8,24 @@ // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%S/Inputs/instr-profile.profdata | FileCheck -check-prefix=PGOUSE %s #ifdef HAVE_FOUNDATION + // Use this to build an instrumented version to regenerate the input file. #import + #else + +// Minimal definitions to get this to compile without Foundation.h. + +@protocol NSObject +@end + +@interface NSObject +- (id)init; ++ (id)alloc; +@end + struct NSFastEnumerationState; -@interface NSArray +@interface NSArray : NSObject - (unsigned long) countByEnumeratingWithState: (struct NSFastEnumerationState*) state objects: (id*) buffer count: (unsigned long) bufferSize; @@ -22,17 +35,26 @@ struct NSFastEnumerationState; // PGOGEN: @[[FOR:__llvm_pgo_ctr[0-9]*]] = private global [2 x i64] zeroinitializer -// PGOGEN-LABEL: @foreach -// PGOUSE-LABEL: @foreach +@interface A : NSObject ++ (void)foreach: (NSArray *)array; +@end + +@implementation A +// PGOGEN-LABEL: define {{.*}}+[A foreach:] +// PGOUSE-LABEL: define {{.*}}+[A foreach:] // PGOGEN: store {{.*}} @[[FOR]], i64 0, i64 0 -void foreach(NSArray *array) { ++ (void)foreach: (NSArray *)array +{ // PGOGEN: store {{.*}} @[[FOR]], i64 0, i64 1 // FIXME: We don't emit branch weights for this yet. for (id x in array) { } } +@end int main(int argc, const char *argv[]) { + A *a = [[A alloc] init]; NSArray *array = [NSArray arrayWithObjects: @"0", @"1", (void*)0]; - foreach(array); + [A foreach: array]; + return 0; } -- cgit v1.2.3