[PATCH] D15243: [PGO]: Do not use invalid Char in instrumentation variable names

David Li via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 12:26:23 PST 2015


davidxl created this revision.
davidxl added reviewers: bogner, vsk.
davidxl added a subscriber: llvm-commits.

: and < are not valid characters for assemblers. See MCAsmInfo::isValidUnquotedName  in MCAsmInfo.cpp and method llvm::printLLVMNameWithoutPrefix in AsmWriter.cpp.

Because this, when the such symbols names emitted in .s file will be quoted which will also upset the assembler.

To reproduce the problem, simply build the following source with option -fprofile-instr-generate -c -no-integrated-as:

static int cmp(int a, int b)
{
   return a > b;
}

extern int foo(int (*)(int, int));

int bar()
{
  return foo(cmp);
}

However there is a downside of this fix -- this is not a backward compatible fix -- once the fix is in, the old version of the indexed profile can not be guaranteed to be usable again (only partially usable) -- the static function's profile data will be dropped (can not be found anymore).

Need more opinion on the impact of partially breaking the old version of indexed format.



http://reviews.llvm.org/D15243

Files:
  lib/ProfileData/InstrProf.cpp

Index: lib/ProfileData/InstrProf.cpp
===================================================================
--- lib/ProfileData/InstrProf.cpp
+++ lib/ProfileData/InstrProf.cpp
@@ -89,9 +89,9 @@
     // that it will stay the same, e.g., if the files are checked out from
     // version control in different locations.
     if (FileName.empty())
-      FuncName = FuncName.insert(0, "<unknown>:");
+      FuncName = FuncName.insert(0, "_unknown_");
     else
-      FuncName = FuncName.insert(0, FileName.str() + ":");
+      FuncName = FuncName.insert(0, FileName.str() + "_");
   }
   return FuncName;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15243.41924.patch
Type: text/x-patch
Size: 603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/8001ba0a/attachment.bin>


More information about the llvm-commits mailing list