[PATCH] D112297: [LTO] Fix assertion failed when flushing bitcode incrementally for LTO output.
Mingjie Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 30 20:00:47 PST 2021
Enna1 updated this revision to Diff 396745.
Enna1 added a comment.
Address review comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112297/new/
https://reviews.llvm.org/D112297
Files:
lld/test/ELF/lto/emit-llvm.ll
llvm/include/llvm/Support/raw_ostream.h
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,10 @@
// 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.
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
+ IsRegularFile = Status.type() == sys::fs::file_type::regular_file;
+ SupportsSeeking = !EC && IsRegularFile;
if (!SupportsSeeking)
pos = 0;
else
Index: llvm/include/llvm/Support/raw_ostream.h
===================================================================
--- llvm/include/llvm/Support/raw_ostream.h
+++ llvm/include/llvm/Support/raw_ostream.h
@@ -444,6 +444,7 @@
int FD;
bool ShouldClose;
bool SupportsSeeking = false;
+ bool IsRegularFile = false;
mutable Optional<bool> HasColors;
#ifdef _WIN32
@@ -514,6 +515,8 @@
bool supportsSeeking() const { return SupportsSeeking; }
+ bool isRegularFile() const { return IsRegularFile; }
+
/// Flushes the stream and repositions the underlying file descriptor position
/// to the offset specified from the beginning of the file.
uint64_t seek(uint64_t off);
Index: lld/test/ELF/lto/emit-llvm.ll
===================================================================
--- lld/test/ELF/lto/emit-llvm.ll
+++ lld/test/ELF/lto/emit-llvm.ll
@@ -4,6 +4,10 @@
; RUN: ld.lld --plugin-opt=emit-llvm -o %t.out.o %t.o
; RUN: llvm-dis < %t.out.o -o - | FileCheck %s
+;; 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.
+; RUN: ld.lld --plugin-opt=emit-llvm -mllvm -bitcode-flush-threshold=0 -o /dev/null %t.o
+
; CHECK: define internal void @main()
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112297.396745.patch
Type: text/x-patch
Size: 2087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211231/ed61030c/attachment.bin>
More information about the llvm-commits
mailing list