From 98a1ca117e6743dd7f2d505443a96f591d083eab Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Sat, 8 Oct 2016 04:47:20 +0000 Subject: [PATCH] [OptRemarks] Remove non-printable chars from function name Value names may be prefixed with a binary '1' to indicate that the backend should not modify the symbols due to any platform naming convention. This should not show up in the YAML opt record file because it breaks the YAML parser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283656 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DiagnosticInfo.h | 2 +- lib/IR/DiagnosticInfo.cpp | 2 ++ test/Transforms/Inline/optimization-remarks-yaml.ll | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/llvm/IR/DiagnosticInfo.h b/include/llvm/IR/DiagnosticInfo.h index 8ae0c1d0ef3..589a0c013ae 100644 --- a/include/llvm/IR/DiagnosticInfo.h +++ b/include/llvm/IR/DiagnosticInfo.h @@ -387,7 +387,7 @@ public: std::string Val; explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {} - Argument(StringRef Key, Value *V) : Key(Key), Val(V->getName()) {} + Argument(StringRef Key, Value *V); Argument(StringRef Key, int N); Argument(StringRef Key, unsigned N); Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {} diff --git a/lib/IR/DiagnosticInfo.cpp b/lib/IR/DiagnosticInfo.cpp index e9187a9ce63..ae10a6dcae6 100644 --- a/lib/IR/DiagnosticInfo.cpp +++ b/lib/IR/DiagnosticInfo.cpp @@ -170,6 +170,8 @@ const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const { getLocation(&Filename, &Line, &Column); return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str(); } +DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Value *V) + : Key(Key), Val(GlobalValue::getRealLinkageName(V->getName())) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N) : Key(Key), Val(itostr(N)) {} diff --git a/test/Transforms/Inline/optimization-remarks-yaml.ll b/test/Transforms/Inline/optimization-remarks-yaml.ll index 870352d3b6d..8c690d9ed4a 100644 --- a/test/Transforms/Inline/optimization-remarks-yaml.ll +++ b/test/Transforms/Inline/optimization-remarks-yaml.ll @@ -50,14 +50,14 @@ target triple = "x86_64-apple-macosx10.11.0" define i32 @baz() !dbg !7 !prof !14 { entry: %call = call i32 (...) @foo(), !dbg !9 - %call1 = call i32 (...) @bar(), !dbg !10 + %call1 = call i32 (...) @"\01bar"(), !dbg !10 %add = add nsw i32 %call, %call1, !dbg !12 ret i32 %add, !dbg !13 } declare i32 @foo(...) -declare i32 @bar(...) +declare i32 @"\01bar"(...) !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!3, !4, !5} -- 2.11.0