Skip to content

Commit

Permalink
Adapt PGO lit-tests to LLVM 9 on Windows
Browse files Browse the repository at this point in the history
The linkage for the counters changed from `internal` to `linkonce_odr
 dso_local`, and the previous regex didn't allow underscores.
  • Loading branch information
kinke committed Sep 21, 2019
1 parent 678b197 commit 3ca8ce9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/PGO/functions.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: && %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \
// RUN: && FileCheck %allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll

// PROFGEN-DAG: @[[SMPL:__(llvm_profile_counters|profc).*simplefunction[A-Za-z0-9]*]] ={{[A-Za-z ]*}} [2 x i64] zeroinitializer
// PROFGEN-DAG: @[[SMPL:__(llvm_profile_counters|profc).*simplefunction[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer
// PROFGEN-DAG: @[[TMPL:__(llvm_profile_counters|profc).*templatefunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer
// PROFGEN-DAG: @[[OUTR:__(llvm_profile_counters|profc).*outerfunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer
// PROFGEN-DAG: @[[NEST:__(llvm_profile_counters|profc).*nestedfunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer
Expand Down
14 changes: 7 additions & 7 deletions tests/PGO/pragma.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern(C):
// CHECK-NOT: @__llvm_profile{{.*}}not_instrumented
// CHECK-NOT: @__prof{{.*}}not_instrumented

// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented ={{[A-Za-z ]*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented ={{.*}} global [1 x i64] zeroinitializer
void instrumented() {}

void not_instrumented() {
Expand All @@ -21,39 +21,39 @@ pragma(LDC_profile_instr, false) {

void not_instrumented_2() {}

// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented2_override ={{[A-Za-z ]*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented2_override ={{.*}} global [1 x i64] zeroinitializer
void instrumented2_override() {
pragma(LDC_profile_instr, true);
}


// CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}instrumented_template{{.*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}instrumented_template{{.*}} global [1 x i64] zeroinitializer
void instrumented_template(T)(T i) {
pragma(LDC_profile_instr, true);
}
void not_instrumented_template(T)(T i) {}

pragma(LDC_profile_instr, true):
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_{{.*}}instantiate_templates{{.*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_{{.*}}instantiate_templates{{.*}} global [1 x i64] zeroinitializer
void instantiate_templates() {
not_instrumented_template(1);
instrumented_template(1);
}

} // pragma(LDC_profile_instr, false)

// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_two ={{[A-Za-z ]*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_two ={{.*}} global [1 x i64] zeroinitializer
void instrumented_two() {}

pragma(LDC_profile_instr, false)
struct Strukt {
void not_instrumented() {}

// CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}Strukt{{.*}}instrumented_method{{.*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}Strukt{{.*}}instrumented_method{{.*}} global [1 x i64] zeroinitializer
void instrumented_method() {
pragma(LDC_profile_instr, true);
}
}

// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_three ={{[A-Za-z ]*}} [1 x i64] zeroinitializer
// CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_three ={{.*}} global [1 x i64] zeroinitializer
void instrumented_three() {}
4 changes: 4 additions & 0 deletions tests/PGO/profile_rt_calls.d
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ void check_counters() {
void main() {
getdataprofile();
check_counters();

// prevent linker stripping
fooC(true, false);
fooCpp(true, false);
}

0 comments on commit 3ca8ce9

Please sign in to comment.