Skip to content

Commit fee9a82

Browse files
authored
Merge pull request #389 from francisvm/57442205/apple/stable/20190619
[Remarks] Allow empty temporary remark files
2 parents 1c2e7b3 + bee2208 commit fee9a82

10 files changed

+14
-1
lines changed

llvm/lib/Remarks/BitstreamRemarkParser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,13 @@ Error BitstreamRemarkParser::processExternalFilePath(
425425
MemoryBuffer::getFile(FullPath);
426426
if (std::error_code EC = BufferOrErr.getError())
427427
return createFileError(FullPath, EC);
428+
428429
TmpRemarkBuffer = std::move(*BufferOrErr);
429430

431+
// Don't try to parse the file if it's empty.
432+
if (TmpRemarkBuffer->getBufferSize() == 0)
433+
return make_error<EndOfFileError>();
434+
430435
// Create a separate parser used for parsing the separate file.
431436
ParserHelper = BitstreamParserHelper(TmpRemarkBuffer->getBuffer());
432437
// Advance and check until we can parse the meta block.

llvm/test/tools/dsymutil/Inputs/basic1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
Remarks compilation:
2424
for FILE in basic1.c basic2.c basic3.c; do
25-
clang -gline-tables-only -c $FILE -fsave-optimization-record=bitstream -foptimization-remarks-file=/tmp/${FILE%.c}.macho.remarks.x86_64.opt.bitstream -mllvm -remarks-section -o ${FILE%.c}.macho.remarks.x86_64.o
25+
clang -gline-tables-only -c $FILE -fsave-optimization-record=bitstream -foptimization-record-file=/remarks/${FILE%.c}.macho.remarks.x86_64.opt.bitstream -o ${FILE%.c}.macho.remarks.x86_64.o
2626
done
2727
clang basic1.macho.remarks.x86_64.o basic2.macho.remarks.x86_64.o basic3.macho.remarks.x86_64.o -o basic.macho.remarks.x86_64 -Wl,-dead_strip
2828
Binary file not shown.
Binary file not shown.

llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.opt.bitstream

Whitespace-only changes.
Binary file not shown.

llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.opt.bitstream

Whitespace-only changes.
Binary file not shown.

llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.opt.bitstream

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RUN: rm -rf %t
2+
RUN: mkdir -p %t
3+
RUN: cat %p/../Inputs/remarks/basic.macho.remarks.empty.x86_64 > %t/basic.macho.remarks.empty.x86_64
4+
5+
RUN: dsymutil -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.empty.x86_64
6+
7+
Check that the remark file in the bundle does not exist:
8+
RUN: not cat %t/basic.macho.remarks.empty.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.empty.x86_64 2>&1

0 commit comments

Comments
 (0)