]> granicus.if.org Git - llvm/commitdiff
[ThinLTO] Escape module paths when printing
authorAndrew Ng <anng.sw@gmail.com>
Thu, 12 Jul 2018 14:40:21 +0000 (14:40 +0000)
committerAndrew Ng <anng.sw@gmail.com>
Thu, 12 Jul 2018 14:40:21 +0000 (14:40 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336908 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/AsmWriter.cpp
test/Assembler/asm-path-writer.ll [new file with mode: 0644]

index 630295a9bd0b73510e5eac26ae9b86df18a4bed0..99a25a723b4a02d6506a2e7ea520ab41262cfe5e 100644 (file)
@@ -2618,8 +2618,9 @@ void AssemblyWriter::printModuleSummaryIndex() {
   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;
diff --git a/test/Assembler/asm-path-writer.ll b/test/Assembler/asm-path-writer.ll
new file mode 100644 (file)
index 0000000..f226395
--- /dev/null
@@ -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)))