Skip to content

Commit

Permalink
[ThinLTO] Escape module paths when printing
Browse files Browse the repository at this point in the history
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

llvm-svn: 336908
  • Loading branch information
nga888 committed Jul 12, 2018
1 parent 8b2ab91 commit ac305e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/IR/AsmWriter.cpp
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/Assembler/asm-path-writer.ll
@@ -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)))

0 comments on commit ac305e1

Please sign in to comment.