Index: lib/ProfileData/InstrProf.cpp =================================================================== --- lib/ProfileData/InstrProf.cpp +++ lib/ProfileData/InstrProf.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Path.h" using namespace llvm; @@ -136,7 +137,7 @@ // data, its original linkage must be non-internal. std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) { if (!InLTO) - return getPGOFuncName(F.getName(), F.getLinkage(), F.getParent()->getName(), + return getPGOFuncName(F.getName(), F.getLinkage(), sys::path::filename(F.getParent()->getName()), Version); // In LTO mode (when InLTO is true), first check if there is a meta data. Index: test/Transforms/PGOProfile/statics_counter_naming.ll =================================================================== --- /dev/null +++ test/Transforms/PGOProfile/statics_counter_naming.ll @@ -0,0 +1,11 @@ +; RUN: opt %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; GEN: @__profn_statics_counter_naming.ll_func = private constant [30 x i8] c"statics_counter_naming.ll:func" + +define internal i32 @func() { +entry: + ret i32 0 +}