[llvm] r336908 - [ThinLTO] Escape module paths when printing
Andrew Ng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 12 07:40:21 PDT 2018
Author: anng
Date: Thu Jul 12 07:40:21 2018
New Revision: 336908
URL: http://llvm.org/viewvc/llvm-project?rev=336908&view=rev
Log:
[ThinLTO] Escape module paths when printing
We have located a bug in AssemblyWriter::printModuleSummaryIndex(). This
function outputs path strings incorrectly. Backslashes in the strings
are not correctly escaped.
Consequently, if a path name contains a backslash followed by two
hexadecimal characters, the sequence is incorrectly interpreted when the
output is read by another component. This mangles the path and results
in error.
This patch fixes this issue by calling printEscapedString() to output
the module paths.
Patch by Chris Jackson.
Differential Revision: https://reviews.llvm.org/D49090
Added:
llvm/trunk/test/Assembler/asm-path-writer.ll
Modified:
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=336908&r1=336907&r2=336908&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu Jul 12 07:40:21 2018
@@ -2618,8 +2618,9 @@ void AssemblyWriter::printModuleSummaryI
unsigned i = 0;
for (auto &ModPair : moduleVec) {
Out << "^" << i++ << " = module: (";
- Out << "path: \"" << ModPair.first << "\"";
- Out << ", hash: (";
+ Out << "path: \"";
+ printEscapedString(ModPair.first, Out);
+ Out << "\", hash: (";
FieldSeparator FS;
for (auto Hash : ModPair.second)
Out << FS << Hash;
Added: llvm/trunk/test/Assembler/asm-path-writer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/asm-path-writer.ll?rev=336908&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/asm-path-writer.ll (added)
+++ llvm/trunk/test/Assembler/asm-path-writer.ll Thu Jul 12 07:40:21 2018
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; CHECK: ^0 = module: (path: ".\5Cf4folder\5Cabc.o", hash: (0, 0, 0, 0, 0))
+
+^0 = module: (path: ".\5Cf4folder\5Cabc.o", hash: (0, 0, 0, 0, 0))
+^1 = gv: (guid: 15822663052811949562, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2)))
More information about the llvm-commits
mailing list