Skip to content

Commit 4506afe

Browse files
committed
[Remarks] Allow empty temporary remark files
When parsing bitstream remarks, allow external remark files to be empty, which means there are no remarks to be parsed. In the same way, dsymutil should not produce a remark file.
1 parent 2692eb0 commit 4506afe

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
@@ -428,8 +428,13 @@ Error BitstreamRemarkParser::processExternalFilePath(
428428
MemoryBuffer::getFile(FullPath);
429429
if (std::error_code EC = BufferOrErr.getError())
430430
return createFileError(FullPath, EC);
431+
431432
TmpRemarkBuffer = std::move(*BufferOrErr);
432433

434+
// Don't try to parse the file if it's empty.
435+
if (TmpRemarkBuffer->getBufferSize() == 0)
436+
return make_error<EndOfFileError>();
437+
433438
// Create a separate parser used for parsing the separate file.
434439
ParserHelper = BitstreamParserHelper(TmpRemarkBuffer->getBuffer());
435440
// 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)