[PATCH] D29512: [PGO] Directory name stripping in global identifier for static functions

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 15:51:08 PST 2017


davidxl added inline comments.


================
Comment at: lib/IR/Globals.cpp:125
+// leave base file name only.
+static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix) {
+  uint32_t Count = NumPrefix; 
----------------
This is PGO specific, probably move the change into InstrProf.cpp including the option etc.


================
Comment at: lib/IR/Globals.cpp:128
+  uint32_t Pos = 0, LastPos = 0;
+  for (auto & CI : PathNameStr) {
+    ++Pos; 
----------------
format fix.


================
Comment at: lib/IR/Globals.cpp:159
+    else {
+      if (StaticFuncStripDirNamePrefix != 0)
+        FileName = stripDirPrefix(FileName, StaticFuncStripDirNamePrefix);
----------------
getGlobalIdentifier is a low level interface. Move this into getPGOFuncName


================
Comment at: test/Transforms/PGOProfile/statics_counter_naming.ll:4
+; RUN: opt %s --pgo-instr-gen -static-func-strip-dirname-prefix=1000 -S | FileCheck %s --check-prefix=GEN
+; RUN: opt %s -passes=pgo-instr-gen -static-func-strip-dirname-prefix=1000 -S | FileCheck %s --check-prefix=GEN
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
----------------
The test does not actually test anything. Better add case that strips the expected separators. 


https://reviews.llvm.org/D29512





More information about the llvm-commits mailing list