[llvm] 4506afe - [Remarks] Allow empty temporary remark files
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 15:58:59 PST 2019
Author: Francis Visoiu Mistrih
Date: 2019-11-22T15:58:12-08:00
New Revision: 4506afe3ca3bda5399a1c0f3ce92f45c670a1930
URL: https://github.com/llvm/llvm-project/commit/4506afe3ca3bda5399a1c0f3ce92f45c670a1930
DIFF: https://github.com/llvm/llvm-project/commit/4506afe3ca3bda5399a1c0f3ce92f45c670a1930.diff
LOG: [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.
Added:
llvm/test/tools/dsymutil/Inputs/remarks/basic.macho.remarks.empty.x86_64
llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.o
llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.opt.bitstream
llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.o
llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.opt.bitstream
llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.o
llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.opt.bitstream
llvm/test/tools/dsymutil/X86/remarks-linking-bundle-empty.test
Modified:
llvm/lib/Remarks/BitstreamRemarkParser.cpp
llvm/test/tools/dsymutil/Inputs/basic1.c
Removed:
################################################################################
diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.cpp b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
index dfad5902545a..4c4508879114 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.cpp
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
@@ -428,8 +428,13 @@ Error BitstreamRemarkParser::processExternalFilePath(
MemoryBuffer::getFile(FullPath);
if (std::error_code EC = BufferOrErr.getError())
return createFileError(FullPath, EC);
+
TmpRemarkBuffer = std::move(*BufferOrErr);
+ // Don't try to parse the file if it's empty.
+ if (TmpRemarkBuffer->getBufferSize() == 0)
+ return make_error<EndOfFileError>();
+
// Create a separate parser used for parsing the separate file.
ParserHelper = BitstreamParserHelper(TmpRemarkBuffer->getBuffer());
// Advance and check until we can parse the meta block.
diff --git a/llvm/test/tools/dsymutil/Inputs/basic1.c b/llvm/test/tools/dsymutil/Inputs/basic1.c
index a41edc927cb4..20292069f5fb 100644
--- a/llvm/test/tools/dsymutil/Inputs/basic1.c
+++ b/llvm/test/tools/dsymutil/Inputs/basic1.c
@@ -22,7 +22,7 @@
Remarks compilation:
for FILE in basic1.c basic2.c basic3.c; do
- 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
+ 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
done
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
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic.macho.remarks.empty.x86_64 b/llvm/test/tools/dsymutil/Inputs/remarks/basic.macho.remarks.empty.x86_64
new file mode 100755
index 000000000000..a730148ba387
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/remarks/basic.macho.remarks.empty.x86_64
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.o b/llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.o
new file mode 100644
index 000000000000..aef4841d64c7
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.opt.bitstream b/llvm/test/tools/dsymutil/Inputs/remarks/basic1.macho.remarks.empty.x86_64.opt.bitstream
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.o b/llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.o
new file mode 100644
index 000000000000..9bb1405bf9e0
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.opt.bitstream b/llvm/test/tools/dsymutil/Inputs/remarks/basic2.macho.remarks.empty.x86_64.opt.bitstream
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.o b/llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.o
new file mode 100644
index 000000000000..fff0a7122fb6
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.opt.bitstream b/llvm/test/tools/dsymutil/Inputs/remarks/basic3.macho.remarks.empty.x86_64.opt.bitstream
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/llvm/test/tools/dsymutil/X86/remarks-linking-bundle-empty.test b/llvm/test/tools/dsymutil/X86/remarks-linking-bundle-empty.test
new file mode 100644
index 000000000000..12418694f144
--- /dev/null
+++ b/llvm/test/tools/dsymutil/X86/remarks-linking-bundle-empty.test
@@ -0,0 +1,8 @@
+RUN: rm -rf %t
+RUN: mkdir -p %t
+RUN: cat %p/../Inputs/remarks/basic.macho.remarks.empty.x86_64 > %t/basic.macho.remarks.empty.x86_64
+
+RUN: dsymutil -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.empty.x86_64
+
+Check that the remark file in the bundle does not exist:
+RUN: not cat %t/basic.macho.remarks.empty.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.empty.x86_64 2>&1
More information about the llvm-commits
mailing list