[PATCH] D112297: [LTO] Fix assertion failed when flushing bitcode incrementally for LTO output.
Xu Mingjie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 28 01:51:55 PDT 2021
Enna1 updated this revision to Diff 382950.
Enna1 edited the summary of this revision.
Enna1 added a comment.
Herald added a subscriber: dexonsmith.
Update patch as @stephan.yichao.zhao @MaskRay suggested.
For both WIN32 and non-WIN32, use the following code to determine `SupportsSeeking `
off_t loc = ::lseek(FD, 0, SEEK_CUR);
sys::fs::file_status Status;
std::error_code EC = status(FD, Status);
if (EC ||
Status.type() == sys::fs::file_type::block_file ||
Status.type() == sys::fs::file_type::character_file) {
SupportsSeeking = false;
} else {
SupportsSeeking = loc != (off_t)-1;
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112297/new/
https://reviews.llvm.org/D112297
Files:
lld/test/ELF/lto/emit-llvm_assertion_failure.ll
llvm/lib/Support/raw_ostream.cpp
Index: llvm/lib/Support/raw_ostream.cpp
===================================================================
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -643,14 +643,16 @@
// Get the starting position.
off_t loc = ::lseek(FD, 0, SEEK_CUR);
-#ifdef _WIN32
- // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes.
+ // Check if supports seeking
sys::fs::file_status Status;
std::error_code EC = status(FD, Status);
- SupportsSeeking = !EC && Status.type() == sys::fs::file_type::regular_file;
-#else
- SupportsSeeking = loc != (off_t)-1;
-#endif
+ if (EC ||
+ Status.type() == sys::fs::file_type::block_file ||
+ Status.type() == sys::fs::file_type::character_file) {
+ SupportsSeeking = false;
+ } else {
+ SupportsSeeking = loc != (off_t)-1;
+ }
if (!SupportsSeeking)
pos = 0;
else
Index: lld/test/ELF/lto/emit-llvm_assertion_failure.ll
===================================================================
--- /dev/null
+++ lld/test/ELF/lto/emit-llvm_assertion_failure.ll
@@ -0,0 +1,14 @@
+; Make sure that if --plugin-opt=emit-llvm is enabled and the output
+; is /dev/null, it should not cause a assertion failure in bitcode writer.
+
+; REQUIRES: x86
+
+; RUN: opt -module-hash -module-summary %s -o %t.o
+; RUN: ld.lld --plugin-opt=emit-llvm -mllvm -bitcode-flush-threshold=0 -o /dev/null %t.o
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @main() {
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112297.382950.patch
Type: text/x-patch
Size: 1560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211028/a4ab4ccb/attachment.bin>
More information about the llvm-commits
mailing list