llvm.org GIT mirror llvm / f5c9f76
[PGO] Don't include full file path in static function profile counter names Patch by Jake VanAdrighem Differential Revision: http://reviews.llvm.org/D22028 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275193 91177308-0d34-0410-b5e6-96231b3b80d8 Xinliang David Li 3 years ago
2 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2222 #include "llvm/Support/ErrorHandling.h"
2323 #include "llvm/Support/LEB128.h"
2424 #include "llvm/Support/ManagedStatic.h"
25 #include "llvm/Support/Path.h"
2526
2627 using namespace llvm;
28
29 static cl::opt StaticFuncFullModulePrefix(
30 "static-func-full-module-prefix", cl::init(false),
31 cl::desc("Use full module build paths in the profile counter names for "
32 "static functions."));
2733
2834 namespace {
2935 std::string getInstrProfErrString(instrprof_error Err) {
134140 // (PGOUseFunc::annotateIndirectCallSites). If a symbol does not have the meta
135141 // data, its original linkage must be non-internal.
136142 std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) {
137 if (!InLTO)
138 return getPGOFuncName(F.getName(), F.getLinkage(), F.getParent()->getName(),
139 Version);
143 if (!InLTO) {
144 StringRef FileName = (StaticFuncFullModulePrefix
145 ? F.getParent()->getName()
146 : sys::path::filename(F.getParent()->getName()));
147 return getPGOFuncName(F.getName(), F.getLinkage(), FileName, Version);
148 }
140149
141150 // In LTO mode (when InLTO is true), first check if there is a meta data.
142151 if (MDNode *MD = getPGOFuncNameMetadata(F)) {
0 ; RUN: opt %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
1 ; RUN: opt %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
4
5 ; GEN: @__profn_statics_counter_naming.ll_func = private constant [30 x i8] c"statics_counter_naming.ll:func"
6
7 define internal i32 @func() {
8 entry:
9 ret i32 0
10 }