[llvm] r275193 - [PGO] Don't include full file path in static function profile counter names
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 12 10:14:51 PDT 2016
Author: davidxl
Date: Tue Jul 12 12:14:51 2016
New Revision: 275193
URL: http://llvm.org/viewvc/llvm-project?rev=275193&view=rev
Log:
[PGO] Don't include full file path in static function profile counter names
Patch by Jake VanAdrighem
Differential Revision: http://reviews.llvm.org/D22028
Added:
llvm/trunk/test/Transforms/PGOProfile/statics_counter_naming.ll
Modified:
llvm/trunk/lib/ProfileData/InstrProf.cpp
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=275193&r1=275192&r2=275193&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Jul 12 12:14:51 2016
@@ -23,9 +23,15 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Path.h"
using namespace llvm;
+static cl::opt<bool> StaticFuncFullModulePrefix(
+ "static-func-full-module-prefix", cl::init(false),
+ cl::desc("Use full module build paths in the profile counter names for "
+ "static functions."));
+
namespace {
std::string getInstrProfErrString(instrprof_error Err) {
switch (Err) {
@@ -135,9 +141,12 @@ std::string getPGOFuncName(StringRef Raw
// (PGOUseFunc::annotateIndirectCallSites). If a symbol does not have the meta
// 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(),
- Version);
+ if (!InLTO) {
+ StringRef FileName = (StaticFuncFullModulePrefix
+ ? F.getParent()->getName()
+ : sys::path::filename(F.getParent()->getName()));
+ return getPGOFuncName(F.getName(), F.getLinkage(), FileName, Version);
+ }
// In LTO mode (when InLTO is true), first check if there is a meta data.
if (MDNode *MD = getPGOFuncNameMetadata(F)) {
Added: llvm/trunk/test/Transforms/PGOProfile/statics_counter_naming.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/statics_counter_naming.ll?rev=275193&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PGOProfile/statics_counter_naming.ll (added)
+++ llvm/trunk/test/Transforms/PGOProfile/statics_counter_naming.ll Tue Jul 12 12:14:51 2016
@@ -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
+}
More information about the llvm-commits
mailing list