Closed berolinux closed 2 years ago
@berolinux could you please provide the preprocessed C/C++ reproducer file & script Clang generates wen crashing? This is need for further investigation.
Also, if you have an assert build, it would be great if you could also share the output of adding -mllvm -print-on-crash -mllvm -print-module-scope
.
Sure, was just waiting for creduce to finish its job.
This is what it comes down to (build with clang++ -O -std=c++20
):
struct a {
long b();
};
struct c {
c(long);
};
class d;
class e;
struct f {
void g(d &);
e *h();
};
struct d {
void i(c);
};
struct e {
int j();
a k;
a l;
} m, n;
void f::g(d &o) {
long p = m.k.b(), q = n.l.b(), r = h()->j();
for (;;) {
long s;
while (s < r)
s += p;
long t = s;
while (t < r)
t += q;
o.i(t);
}
}
$ clang++ -O -std=c++20 -mllvm -print-on-crash -mllvm -print-module-scope svdpagv.cpp
clang-15: /builddir/build/BUILD/llvm-project-release-15.x/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = llvm::PHINode, From = llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, false>]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/bin/clang-15 -cc1 -triple x86_64-pc-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name svdpagv.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/bero/temp/abf/libreoffice/BUILD/libreoffice-7.4.1.1 -resource-dir /usr/lib64/clang/15.0.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.2.0/../../../../include/c++/12.2.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-openmandriva-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward -internal-isystem /usr/lib64/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.2.0/../../../../x86_64-openmandriva-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/bero/temp/abf/libreoffice/BUILD/libreoffice-7.4.1.1 -ferror-limit 19 -fgnuc-version=12.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -mllvm -print-on-crash -mllvm -print-module-scope -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/svdpagv-d54f53.o -x c++ svdpagv.cpp
1. <eof> parser at end of file
2. Optimizer
#0 0x00007fd119a90a01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM-15.so+0x41d0a01)
#1 0x00007fd119a90d9b (/lib64/libLLVM-15.so+0x41d0d9b)
#2 0x00007fd119a8f64a llvm::sys::RunSignalHandlers() (/lib64/libLLVM-15.so+0x41cf64a)
#3 0x00007fd119a902f6 (/lib64/libLLVM-15.so+0x41d02f6)
#4 0x00007fd1154d42a0 (/lib64/libc.so.6+0x382a0)
#5 0x00007fd115523ffc (/lib64/libc.so.6+0x87ffc)
#6 0x00007fd1154d41f2 raise (/lib64/libc.so.6+0x381f2)
#7 0x00007fd1154be472 abort (/lib64/libc.so.6+0x22472)
#8 0x00007fd1154be395 (/lib64/libc.so.6+0x22395)
#9 0x00007fd1154ccf12 (/lib64/libc.so.6+0x30f12)
#10 0x00007fd11addedde (/lib64/libLLVM-15.so+0x551edde)
#11 0x00007fd11ade6d9b (/lib64/libLLVM-15.so+0x5526d9b)
#12 0x00007fd11ade350a llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/lib64/libLLVM-15.so+0x552350a)
#13 0x00007fd11da02def (/lib64/libLLVM-15.so+0x8142def)
#14 0x00007fd119d36354 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/lib64/libLLVM-15.so+0x4476354)
#15 0x00007fd11c68fcbf (/lib64/libLLVM-15.so+0x6dcfcbf)
#16 0x00007fd11b731d59 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/lib64/libLLVM-15.so+0x5e71d59)
#17 0x00007fd11c68f8df (/lib64/libLLVM-15.so+0x6dcf8df)
#18 0x00007fd11b7296f5 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/lib64/libLLVM-15.so+0x5e696f5)
#19 0x00007fd11b3a0d8f (/lib64/libLLVM-15.so+0x5ae0d8f)
#20 0x00007fd11b72ea4c llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/lib64/libLLVM-15.so+0x5e6ea4c)
#21 0x00007fd11b3a075f (/lib64/libLLVM-15.so+0x5ae075f)
#22 0x00007fd11b72bee2 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib64/libLLVM-15.so+0x5e6bee2)
#23 0x00007fd11b3a0abf (/lib64/libLLVM-15.so+0x5ae0abf)
#24 0x00007fd119d32e20 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib64/libLLVM-15.so+0x4472e20)
#25 0x00007fd11b3a02c8 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib64/libLLVM-15.so+0x5ae02c8)
#26 0x00007fd11da0bf1f (/lib64/libLLVM-15.so+0x814bf1f)
#27 0x00007fd119d32e20 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib64/libLLVM-15.so+0x4472e20)
#28 0x00007fd121249c3f (/lib64/libclang-cpp.so.15+0x2a02c3f)
#29 0x00007fd121242c84 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/lib64/libclang-cpp.so.15+0x29fbc84)
#30 0x00007fd12166ee66 (/lib64/libclang-cpp.so.15+0x2e27e66)
#31 0x00007fd11ff17ece clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.15+0x16d0ece)
#32 0x00007fd12212c8ef clang::ASTFrontendAction::ExecuteAction() (/lib64/libclang-cpp.so.15+0x38e58ef)
#33 0x00007fd121667de9 clang::CodeGenAction::ExecuteAction() (/lib64/libclang-cpp.so.15+0x2e20de9)
#34 0x00007fd12212c6bb clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.15+0x38e56bb)
#35 0x00007fd12208207b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.15+0x383b07b)
#36 0x00007fd1221a49c2 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.15+0x395d9c2)
#37 0x000000000021928e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-15+0x21928e)
#38 0x0000000000215b5d (/usr/bin/clang-15+0x215b5d)
#39 0x00000000002154be clang_main(int, char**) (/usr/bin/clang-15+0x2154be)
#40 0x0000000000226243 main (/usr/bin/clang-15+0x226243)
#41 0x00007fd1154bf18a (/lib64/libc.so.6+0x2318a)
#42 0x00007fd1154bf245 __libc_start_main (/lib64/libc.so.6+0x23245)
#43 0x0000000000212081 _start (/usr/bin/clang-15+0x212081)
*** Dump of Module IR Before Last Pass InstCombinePass Started ***
; ModuleID = 'svdpagv.cpp'
source_filename = "svdpagv.cpp"
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-pc-linux-gnu"
%struct.e = type { %struct.a, %struct.a }
%struct.a = type { i8 }
%struct.c = type { i8 }
@m = dso_local global %struct.e zeroinitializer, align 1
@n = dso_local global %struct.e zeroinitializer, align 1
; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_ZN1f1gER1d(ptr noundef nonnull align 1 dereferenceable(1) %this, ptr noundef nonnull align 1 dereferenceable(1) %o) local_unnamed_addr #0 align 2 {
entry:
%agg.tmp = alloca %struct.c, align 1
%call = call noundef i64 @_ZN1a1bEv(ptr noundef nonnull align 1 dereferenceable(1) @m)
%call2 = call noundef i64 @_ZN1a1bEv(ptr noundef nonnull align 1 dereferenceable(1) getelementptr inbounds (%struct.e, ptr @n, i64 0, i32 1))
%call3 = call noundef ptr @_ZN1f1hEv(ptr noundef nonnull align 1 dereferenceable(1) %this)
%call4 = call noundef i32 @_ZN1e1jEv(ptr noundef nonnull align 1 dereferenceable(2) %call3)
%conv = sext i32 %call4 to i64
%umax = call i64 @llvm.umax.i64(i64 %call, i64 1)
%umax17 = call i64 @llvm.umax.i64(i64 %call2, i64 1)
br label %for.cond
for.cond: ; preds = %while.end9, %entry
%s.0 = phi i64 [ undef, %entry ], [ %5, %while.end9 ]
%smax = call i64 @llvm.smax.i64(i64 %s.0, i64 %conv)
%0 = sub i64 %smax, %s.0
%umin = call i64 @llvm.umin.i64(i64 %0, i64 1)
%1 = sub i64 %0, %umin
%2 = udiv i64 %1, %umax
%3 = add i64 %umin, %2
%4 = mul i64 %call, %3
br label %while.cond5.preheader
while.cond5.preheader: ; preds = %for.cond
%5 = add i64 %s.0, %4
%6 = add i64 %s.0, %4
%smax15 = call i64 @llvm.smax.i64(i64 %5, i64 %conv)
%7 = sub i64 %smax15, %5
%umin16 = call i64 @llvm.umin.i64(i64 %7, i64 1)
br label %while.cond5
while.cond5: ; preds = %while.cond5, %while.cond5.preheader
%8 = sub i64 %smax15, %umin16
%9 = sub i64 %8, %5
%10 = udiv i64 %9, %umax17
%11 = add i64 %umin16, %10
%12 = mul i64 %call2, %11
%13 = add i64 %6, %12
%t.0 = phi i64 [ %add8, %while.cond5 ], [ %5, %while.cond5.preheader ]
%cmp6 = icmp slt i64 %t.0, %conv
%add8 = add nsw i64 %t.0, %call2
br i1 %cmp6, label %while.cond5, label %while.end9, !llvm.loop !5
while.end9: ; preds = %while.cond5
%t.0.lcssa = phi i64 [ %13, %while.cond5 ]
call void @_ZN1cC1El(ptr noundef nonnull align 1 dereferenceable(1) %agg.tmp, i64 noundef %t.0.lcssa)
call void @_ZN1d1iE1c(ptr noundef nonnull align 1 dereferenceable(1) %o)
br label %for.cond, !llvm.loop !8
}
declare noundef i64 @_ZN1a1bEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1
declare noundef ptr @_ZN1f1hEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1
declare noundef i32 @_ZN1e1jEv(ptr noundef nonnull align 1 dereferenceable(2)) local_unnamed_addr #1
declare void @_ZN1d1iE1c(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1
declare void @_ZN1cC1El(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef) unnamed_addr #1
; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare i64 @llvm.smax.i64(i64, i64) #2
; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare i64 @llvm.umin.i64(i64, i64) #2
; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare i64 @llvm.umax.i64(i64, i64) #2
attributes #0 = { mustprogress noreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"OpenMandriva 15.0.0-0.20220826.1 clang version 15.0.0 (/builddir/build/BUILD/llvm-project-release-15.x/clang b12227227093f5113fa12506a13d796070398270)"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = distinct !{!8, !6, !7}
clang-15: error: unable to execute command: Aborted (core dumped)
clang-15: error: clang frontend command failed due to signal (use -v to see invocation)
OpenMandriva 15.0.0-0.20220826.1 clang version 15.0.0 (/builddir/build/BUILD/llvm-project-release-15.x/clang b12227227093f5113fa12506a13d796070398270)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Thanks! Looks like the same issue as #57336
We should probably pick the fix for the release. @preames WDYT?
/cherry-pick c37b1a5f764380f83ba08ae0cebca2b162123eb6
/branch llvm/llvm-project-release-prs/issue57511
/pull-request llvm/llvm-project-release-prs#142
Thanks! Looks like the same issue as #57336
We should probably pick the fix for the release. @preames WDYT?
No objection. Seems like a reasonable backport.
Great, thanks @nikic for already triggering the cherry-pick
confirmed to fix libreoffice build
Thanks @berolinux for the quick responses!
Trying to build libreoffice 7.4.1.1 with clang 15-rc3 results in: