Skip to content

Commit

Permalink
[PGO] Fix tests on Win x86. Add testcase for extern(C++) function pas…
Browse files Browse the repository at this point in the history
…sed as template alias parameter.
  • Loading branch information
JohanEngelen committed May 29, 2016
1 parent ce0692a commit 5176b3e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
13 changes: 12 additions & 1 deletion runtime/profile-rt/d/ldc/profile.d
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,18 @@ const(ProfileData)* getData(string funcname)
const(ProfileData)* getData(alias F)()
// TODO: add constraint on F
{
return getData(F.mangleof);
version(Win32)
{
import std.traits : functionLinkage;
static if (functionLinkage!F == "D")
return getData("_" ~ mangledName);
else
return getData(mangledName);
}
else
{
return getData(mangledName);
}
}

/**
Expand Down
16 changes: 8 additions & 8 deletions tests/PGO/functions.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
// PROFGEN-NOT: @{{__profc.*fwddecl.*}}


// PROFGEN-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}simplefunction{{[A-Za-z0-9]*}}(
// PROFUSE-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}simplefunction{{[A-Za-z0-9]*}}(
// PROFGEN-LABEL: define {{.*}} @{{.*}}simplefunction{{.*}}(
// PROFUSE-LABEL: define {{.*}} @{{.*}}simplefunction{{.*}}(
// PROFGEN: store {{.*}} @[[SMPL]], i64 0, i64 0
// PROFUSE-SAME: !prof ![[SMPL0:[0-9]+]]
void simplefunction(int i) {
Expand All @@ -38,8 +38,8 @@ void simplefunction(int i) {
}


// PROFGEN-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}templatefunc{{[A-Za-z0-9]*}}(
// PROFUSE-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}templatefunc{{[A-Za-z0-9]*}}(
// PROFGEN-LABEL: define {{.*}} @{{.*}}templatefunc{{.*}}(
// PROFUSE-LABEL: define {{.*}} @{{.*}}templatefunc{{.*}}(
// PROFGEN: store {{.*}} @[[TMPL]], i64 0, i64 0
// PROFUSE-SAME: !prof ![[TMPL0:[0-9]+]]
void templatefunc(T)(T i) {
Expand All @@ -54,14 +54,14 @@ void call_templatefunc(int i) {
}


// PROFGEN-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}outerfunc{{[A-Za-z0-9]*}}(
// PROFUSE-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}outerfunc{{[A-Za-z0-9]*}}(
// PROFGEN-LABEL: define {{.*}} @{{.*}}outerfunc{{.*}}(
// PROFUSE-LABEL: define {{.*}} @{{.*}}outerfunc{{.*}}(
// PROFGEN: store {{.*}} @[[OUTR]], i64 0, i64 0
// PROFUSE-SAME: !prof ![[OUTR0:[0-9]+]]
// PROFGEN: store {{.*}} @[[OUTR]], i64 0, i64 1
// PROFUSE: br {{.*}} !prof ![[OUTR1:[0-9]+]]
// PROFGEN-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}nestedfunc{{[A-Za-z0-9]*}}(
// PROFUSE-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}nestedfunc{{[A-Za-z0-9]*}}(
// PROFGEN-LABEL: define {{.*}} @{{.*}}nestedfunc{{.*}}(
// PROFUSE-LABEL: define {{.*}} @{{.*}}nestedfunc{{.*}}(
// PROFGEN: store {{.*}} @[[NEST]], i64 0, i64 0
// PROFUSE-SAME: !prof ![[NEST0:[0-9]+]]
// PROFGEN: store {{.*}} @[[NEST]], i64 0, i64 1
Expand Down
4 changes: 4 additions & 0 deletions tests/PGO/profile_rt_calls.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ldc.profile;

bool foo(bool a, bool b) { return a ? a : b; }
bool bar(bool a, bool b) { return a ? a : b; }
extern(C) bool fooC(bool a, bool b) { return a; }
extern(C++) bool fooCpp(bool a, bool b) { return a; }

bool notinstrumented(bool a, bool b) {
pragma(LDC_profile_instr, false)
Expand All @@ -16,6 +18,8 @@ extern(C) void getdataprofile() {
assert( getData("unknown function") == null );
assert( getData("getdataprofile") != null );
assert( getData!foo != null );
assert( getData!fooC != null );
assert( getData!fooCpp != null );
assert( getData!notinstrumented == null );
}

Expand Down

0 comments on commit 5176b3e

Please sign in to comment.