I'm compiling kernel-5.5.4 with LLVM/clang-10.0.x on i686
Build details and logs can be found here
https://abf.openmandriva.org/build_lists/709792
clang -Wp,-MD,drivers/char/.random.o.d -nostdinc -isystem /usr/lib/clang/10.0.0/include -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -Qunused-arguments -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -no-integrated-as -Werror=unknown-warning-option -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m32 -msoft-float -mregparm=3 -freg-struct-return -fno-pic -mstack-alignment=4 -march=i686 -mtune=generic -Wa,-mtune=generic32 -ffreestanding -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -fno-delete-null-pointer-checks -Wno-address-of-packed-member -O2 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-format-invalid-specifier -Wno-gnu -Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -fmacro-prefix-map=./= -fcf-protection=none -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -DKBUILD_BASENAME='"random"' -DKBUILD_MODNAME='"random"' -c -o drivers/char/random.o drivers/char/random.c
BUILDSTDERR: clang-10: /builddir/build/BUILD/llvm-project-release-10.x/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:750: llvm::BasicBlock *llvm::SplitBlockPredecessors(llvm::BasicBlock *, ArrayRef<llvm::BasicBlock *>, const char *, llvm::DominatorTree *, llvm::LoopInfo *, llvm::MemorySSAUpdater *, bool): Assertion `!isa<CallBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from a CallBrInst"' failed.
BUILDSTDERR: Stack dump:
BUILDSTDERR: 0. Program arguments: /usr/bin/clang-10 -cc1 -triple i686-pc-linux-gnu -S -disable-free -main-file-name random.c -mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks -mllvm -warn-stack-size=1024 -mregparm 3 -freg-struct-return -mframe-pointer=all -relaxed-aliasing -mdisable-tail-calls -fmath-errno -fno-rounding-math -masm-verbose -no-integrated-as -mconstructor-aliases -ffreestanding -target-cpu i686 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse -target-feature -mmx -target-feature -sse2 -target-feature -3dnow -target-feature -avx -target-feature +retpoline-external-thunk -no-implicit-float -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/clang/10.0.0 -dependency-file drivers/char/.random.o.d -MT drivers/char/random.o -sys-header-deps -isystem /usr/lib/clang/10.0.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/x86/include -I ./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D __KERNEL__ -D CONFIG_AS_CFI=1 -D CONFIG_AS_CFI_SIGNAL_FRAME=1 -D CONFIG_AS_CFI_SECTIONS=1 -D CONFIG_AS_SSSE3=1 -D CONFIG_AS_AVX=1 -D CONFIG_AS_AVX2=1 -D CONFIG_AS_AVX512=1 -D CONFIG_AS_SHA1_NI=1 -D CONFIG_AS_SHA256_NI=1 -D CC_USING_FENTRY -D KBUILD_BASENAME="random" -D KBUILD_MODNAME="random" -fmacro-prefix-map=./= -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -Werror=unknown-warning-option -Wno-sign-compare -Wno-address-of-packed-member -Wno-format-invalid-specifier -Wno-gnu -Wno-tautological-compare -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir /builddir/build/BUILD/linux-5.5 -ferror-limit 19 -fmessage-length 0 -pg -mfentry -fwrapv -stack-protector 2 -mstack-alignment=4 -fcf-protection=none -fwchar-type=short -fno-signed-wchar -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /tmp/random-f9dbdd.s -x c drivers/char/random.c
BUILDSTDERR: 1. <eof> parser at end of file
BUILDSTDERR: 2. Per-module optimization passes
BUILDSTDERR: 3. Running pass 'CallGraph Pass Manager' on module 'drivers/char/random.c'.
BUILDSTDERR: 4. Running pass 'Loop Pass Manager' on function '@write_pool'
BUILDSTDERR: 5. Running pass 'Loop Invariant Code Motion' on basic block '%for.body'
BUILDSTDERR: #0 0xf1c056cf (/usr/lib/libLLVMSupport.so.10.0+0x21e6cf)
BUILDSTDERR: #1 0xf1c0293e llvm::sys::RunSignalHandlers() (/usr/lib/libLLVMSupport.so.10.0+0x21b93e)
BUILDSTDERR: #2 0xf1c058dc (/usr/lib/libLLVMSupport.so.10.0+0x21e8dc)
BUILDSTDERR: #3 0xf7ef7c90 (linux-gate.so.1+0xc90)
BUILDSTDERR: #4 0xf7ef7c79 (linux-gate.so.1+0xc79)
BUILDSTDERR: #5 0xf162dc42 raise (/lib/libc.so.6+0x3dc42)
BUILDSTDERR: #6 0xf160d30b abort (/lib/libc.so.6+0x1d30b)
BUILDSTDERR: #7 0xf160d1d3 plural_eval.cold (/lib/libc.so.6+0x1d1d3)
BUILDSTDERR: #8 0xf161e60b (/lib/libc.so.6+0x2e60b)
BUILDSTDERR: #9 0xf2ab5923 llvm::SplitBlockPredecessors(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) (/usr/lib/libLLVMTransformUtils.so.10.0+0xf3923)
BUILDSTDERR: #10 0xf38b1768 llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::Loop*, llvm::AliasSetTracker*, llvm::MemorySSAUpdater*, llvm::ICFLoopSafetyInfo*, llvm::SinkAndHoistLICMFlags&, llvm::OptimizationRemarkEmitter*) (/usr/lib/libLLVMScalarOpts.so.10.0+0x282768)
BUILDSTDERR: #11 0xf38ae910 (/usr/lib/libLLVMScalarOpts.so.10.0+0x27f910)
BUILDSTDERR: #12 0xf38bc134 (/usr/lib/libLLVMScalarOpts.so.10.0+0x28d134)
BUILDSTDERR: #13 0xf283330c llvm::LPPassManager::runOnFunction(llvm::Function&) (/usr/lib/libLLVMAnalysis.so.10.0+0x40130c)
BUILDSTDERR: #14 0xf209f1c6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/libLLVMCore.so.10.0+0x3861c6)
BUILDSTDERR: #15 0xf2705383 (/usr/lib/libLLVMAnalysis.so.10.0+0x2d3383)
BUILDSTDERR: #16 0xf209fd88 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/libLLVMCore.so.10.0+0x386d88)
BUILDSTDERR: #17 0xf20a0627 llvm::legacy::PassManager::run(llvm::Module&) (/usr/lib/libLLVMCore.so.10.0+0x387627)
BUILDSTDERR: #18 0xf47d5188 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/usr/lib/libclangCodeGen.so.10.0+0x23a188)
BUILDSTDERR: #19 0xf4bc052a (/usr/lib/libclangCodeGen.so.10.0+0x62552a)
BUILDSTDERR: #20 0xef90141c clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/libclangParse.so.10.0+0x6a41c)
BUILDSTDERR: #21 0xf32a61d5 clang::ASTFrontendAction::ExecuteAction() (/usr/lib/libclangFrontend.so.10.0+0x1571d5)
BUILDSTDERR: #22 0xf4bbb415 clang::CodeGenAction::ExecuteAction() (/usr/lib/libclangCodeGen.so.10.0+0x620415)
BUILDSTDERR: #23 0xf32a58dd clang::FrontendAction::Execute() (/usr/lib/libclangFrontend.so.10.0+0x1568dd)
BUILDSTDERR: #24 0xf32386a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/libclangFrontend.so.10.0+0xe96a6)
BUILDSTDERR: #25 0xf544185f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/libclangFrontendTool.so.10.0+0x585f)
BUILDSTDERR: #26 0x00415d93 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-10+0x415d93)
BUILDSTDERR: #27 0x00413b49 (/usr/bin/clang-10+0x413b49)
BUILDSTDERR: #28 0x00412e93 main (/usr/bin/clang-10+0x412e93)
BUILDSTDERR: #29 0xf160ef61 __libc_start_main (/lib/libc.so.6+0x1ef61)
BUILDSTDERR: #30 0x0040f351 _start (/usr/bin/clang-10+0x40f351)
BUILDSTDERR: clang-10: error: unable to execute command: Aborted (core dumped)
BUILDSTDERR: clang-10: error: clang frontend command failed due to signal (use -v to see invocation)
BUILDSTDERR: clang version 10.0.0
BUILDSTDERR: Target: i686-pc-linux-gnu
BUILDSTDERR: Thread model: posix
BUILDSTDERR: InstalledDir: /usr/bin
BUILDSTDERR: clang-10: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
BUILDSTDERR: clang-10: note: diagnostic msg:
BUILDSTDERR: ********************
BUILDSTDERR: PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
BUILDSTDERR: Preprocessed source(s) and associated run script(s) are located at:
BUILDSTDERR: clang-10: note: diagnostic msg: /tmp/random-99c0b6.c
BUILDSTDERR: clang-10: note: diagnostic msg: /tmp/random-99c0b6.sh
BUILDSTDERR: clang-10: note: diagnostic msg:
BUILDSTDERR: ********************
BUILDSTDERR: make[2]: *** [scripts/Makefile.build:265: drivers/char/random.o] Error 254
BUILDSTDERR: make[2]: *** Waiting for unfinished jobs....
This is still reproducible on ToT LLVM and Linux. I'll reduce this down and report it upstream.
This is a regression in 10.0.0, as 9.0.1 is fine. I'm running a bisect now.
creduce spits out:
c;
enum { a, b } e() {
asm goto("" : : : : d);
return b;
d:
return a;
}
h(*f) {
_Bool g;
asm("" : "=@ccc"(g), "=a"(*f));
if (g)
return b;
return a;
}
_Bool i(f) { return e() ? h(f) : a; }
j() {
int k;
for (;;)
if (!i(&k))
break;
c = k;
}
Run the below with opt -licm foo.ll and it reproduces the failure.
source_filename = "bug2.c"
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i386-unknown-linux-gnu"
define dso_local i32 @j() local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %cond.true.i, %entry
callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@j, %for.end)) #1
to label %cond.true.i [label %for.end]
cond.true.i: ; preds = %for.cond
%asmresult1.i.i = extractvalue { i8, i32 } zeroinitializer, 1
br i1 undef, label %for.end, label %for.cond
for.end: ; preds = %cond.true.i, %for.cond
%asmresult1.i.i2 = phi i32 [ %asmresult1.i.i, %cond.true.i ], [ undef, %for.cond ]
ret i32 undef
}
attributes #0 = { "use-soft-float"="false" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
!0 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git faf74f0b2b2e51989780a95d4f1466fd6e1beb80)"}
I think this is the fix:
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 6e5870c1844..15d40a50e60 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1489,7 +1489,8 @@ static bool canSplitPredecessors(PHINode *PN, LoopSafetyInfo *SafetyInfo) {
return false;
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
BasicBlock *BBPred = *PI;
- if (isa<IndirectBrInst>(BBPred->getTerminator()))
+ if (isa<IndirectBrInst>(BBPred->getTerminator()) ||
+ isa<CallBrInst>(BBPred->getTerminator()))
return false;
}
return true;
Bisect points to https://github.com/llvm/llvm-project/commit/cc95a45f8a53a072773936570901af4a84f55409, don鈥檛 know if that is accurate or I took a wrong turn somewhere (I tried to do it automatically and might have messed something up).
I can try that patch later.
I think llvm/llvm-project@cc95a45 just exposed the issue. The change of the extractvalue to "free" probably tipped things off so that LICM would fail.
This is weird, I cannot reproduce on master/ToT llvm. Is this only reproducible in clang-10?
I could reproduce it with ToT LLVM this morning.
$ make CC=clang i386_defconfig
$ make CC=clang drivers/char/random.o
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
CC drivers/char/random.o
$ git show -1 | head -n1
commit ca7e1fd1026c5af6a533b4b5447e1d2f153e28f2
$ clang -O2 -no-integrated-as -march=i686 -m32 -c -o /dev/null tmp.c
$ echo $?
0
Compiler is haunted, 馃懟 , confirmed.
$ opt -licm foo.ll -S
; ModuleID = 'foo.ll'
source_filename = "foo.ll"
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i386-unknown-linux-gnu"
define dso_local i32 @j() local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %cond.true.i, %entry
callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@j, %for.end)) #1
to label %cond.true.i [label %for.end]
cond.true.i: ; preds = %for.cond
br i1 true, label %for.end, label %for.cond
for.end: ; preds = %cond.true.i, %for.cond
%asmresult1.i.i2 = phi i32 [ 0, %cond.true.i ], [ undef, %for.cond ]
ret i32 undef
}
attributes #0 = { "use-soft-float"="false" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
!0 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git faf74f0b2b2e51989780a95d4f1466fd6e1beb80)"}
in Bill's reproducer, there's a weird branch on undef.
Sorry, needs OpenMandriva鈥檚 common.config (dump it into kernel/configs then run make i386_defconfig common.config) then it should be reproducible.
https://github.com/OpenMandrivaAssociation/kernel-release-clang/blob/master/common.config
I have a Clang built from yesterday:
commit 6990eaf1fe00e9736fbfbcae160e18c5edbcd1d4
With @nathanchance's reproducer, I see the expected crash.
srhines@ringworld:__:~$ /disk/llvm/build/bin/clang -O2 -c -m32 tmp.c
tmp.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
c; ^
tmp.c:8:4: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
h(*f) {
^
tmp.c:8:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
h(*f) {
^
tmp.c:15:29: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with & [-Wint-conversion]
_Bool i(f) { return e() ? h(f) : a; }
^
&
tmp.c:8:4: note: passing argument to parameter 'f' here
h(*f) {
^
tmp.c:16:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
j() {
^
tmp.c:19:20: warning: incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove & [-Wint-conversion]
if (!i(&k))
^~
tmp.c:22:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
clang: /disk/llvm/llvm-project/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:751: llvm::BasicBlock *llvm::SplitBlockPredecessors(llvm::BasicBlock *, ArrayRef<llvm::BasicBlock *>, const char *, llvm::DominatorTree *, llvm::LoopInfo *, llvm::MemorySSAUpdater *, bool): Assertion `!isa
<CallBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from a CallBrInst"' failed.
Stack dump:
0. Program arguments: /disk/llvm/build/bin/clang -O2 -c -m32 tmp.c
1. <eof> parser at end of file
2. Per-module optimization passes
3. Running pass 'CallGraph Pass Manager' on module 'tmp.c'.
4. Running pass 'Loop Pass Manager' on function '@j'
5. Running pass 'Loop Invariant Code Motion' on basic block '%for.cond'
#0 0x0000000003f84a87 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/disk/llvm/build/bin/clang+0x3f84a87)
#1 0x0000000003f84c29 PrintStackTraceSignalHandler(void*) (/disk/llvm/build/bin/clang+0x3f84c29)
#2 0x0000000003f8343b llvm::sys::RunSignalHandlers() (/disk/llvm/build/bin/clang+0x3f8343b)
#3 0x0000000003f8437e llvm::sys::CleanupOnSignal(unsigned long) (/disk/llvm/build/bin/clang+0x3f8437e)
#4 0x0000000003e88988 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/disk/llvm/build/bin/clang+0x3e88988)
#5 0x0000000003e88c0e CrashRecoverySignalHandler(int) (/disk/llvm/build/bin/clang+0x3e88c0e)
#6 0x00007f39dfcce520 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13520)
#7 0x00007f39df79e081 raise /build/glibc-G5rUEF/glibc-2.29/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#8 0x00007f39df789535 abort /build/glibc-G5rUEF/glibc-2.29/stdlib/abort.c:81:7
#9 0x00007f39df78940f _nl_load_domain /build/glibc-G5rUEF/glibc-2.29/intl/loadmsgcat.c:1177:9
#10 0x00007f39df796b92 (/lib/x86_64-linux-gnu/libc.so.6+0x32b92)
#11 0x0000000003f9f64e llvm::SplitBlockPredecessors(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) (/disk/llvm/build/bin/clang+0x3f9f64e)
#12 0x0000000003c30c49 splitPredecessorsOfLoopExit(llvm::PHINode*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::Loop const*, llvm::LoopSafetyInfo*, llvm::MemorySSAUpdater*) (/disk/llvm/build/bin/clang+0x3c30c49)
#13 0x0000000003c2a111 sink(llvm::Instruction&, llvm::LoopInfo*, llvm::DominatorTree*, llvm::Loop const*, llvm::ICFLoopSafetyInfo*, llvm::MemorySSAUpdater*, llvm::OptimizationRemarkEmitter*) (/disk/llvm/build/bin/clang+0x3c2a111)
#14 0x0000000003c28b7c llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::Loop*, llvm::AliasSetTracker*, llvm::MemorySSAUpdater*, llvm::ICFLoopSafetyInfo*, l
lvm::SinkAndHoistLICMFlags&, llvm::OptimizationRemarkEmitter*) (/disk/llvm/build/bin/clang+0x3c28b7c)
#15 0x0000000003c27bc6 (anonymous namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*, llvm::OptimizationRemarkEmitter*) (
/disk/llvm/build/bin/clang+0x3c27bc6)
#16 0x0000000003c2f65b (anonymous namespace)::LegacyLICMPass::runOnLoop(llvm::Loop*, llvm::LPPassManager&) (/disk/llvm/build/bin/clang+0x3c2f65b)
#17 0x0000000002bf59ee llvm::LPPassManager::runOnFunction(llvm::Function&) (/disk/llvm/build/bin/clang+0x2bf59ee)
#18 0x00000000035025bc llvm::FPPassManager::runOnFunction(llvm::Function&) (/disk/llvm/build/bin/clang+0x35025bc)
#19 0x0000000002ad9b4b (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, llvm::CallGraphSCC&, llvm::CallGraph&, bool&, bool&) (/disk/llvm/build/bin/clang+0x2ad9b4b)
#20 0x0000000002ad9469 (anonymous namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&, llvm::CallGraph&, bool&) (/disk/llvm/build/bin/clang+0x2ad9469)
#21 0x0000000002ad8dd8 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) (/disk/llvm/build/bin/clang+0x2ad8dd8)
#22 0x0000000003503164 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) (/disk/llvm/build/bin/clang+0x3503164)
#23 0x0000000003502c88 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/disk/llvm/build/bin/clang+0x3502c88)
#24 0x0000000003503701 llvm::legacy::PassManager::run(llvm::Module&) (/disk/llvm/build/bin/clang+0x3503701)
#25 0x00000000042f7f07 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/disk/llvm/build/bin/clang+0x42f7f07)
#26 0x00000000042f404b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::ra
w_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/disk/llvm/build/bin/clang+0x42f404b)
#27 0x00000000055c93e6 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/disk/llvm/build/bin/clang+0x55c93e6)
#28 0x0000000006d5625e clang::ParseAST(clang::Sema&, bool, bool) (/disk/llvm/build/bin/clang+0x6d5625e)
#29 0x0000000004bc0c52 clang::ASTFrontendAction::ExecuteAction() (/disk/llvm/build/bin/clang+0x4bc0c52)
#30 0x00000000055c5836 clang::CodeGenAction::ExecuteAction() (/disk/llvm/build/bin/clang+0x55c5836)
#31 0x0000000004bc0618 clang::FrontendAction::Execute() (/disk/llvm/build/bin/clang+0x4bc0618)
#32 0x0000000004b4fced clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/disk/llvm/build/bin/clang+0x4b4fced)
#33 0x0000000004d548e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/disk/llvm/build/bin/clang+0x4d548e9)
#34 0x000000000119d26e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/disk/llvm/build/bin/clang+0x119d26e)
#35 0x0000000001190d42 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/disk/llvm/build/bin/clang+0x1190d42)
#36 0x0000000004a4b298 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1::operator()() const (/disk/llvm/build/bin/clang+0x4a4b298)
#37 0x0000000004a4b265 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1>(long) (/disk/llvm/build/bin
/clang+0x4a4b265)
#38 0x0000000003e88f39 llvm::function_ref<void ()>::operator()() const (/disk/llvm/build/bin/clang+0x3e88f39)
#39 0x0000000003e88774 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/disk/llvm/build/bin/clang+0x3e88774)
#40 0x0000000004a4a726 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/disk/llvm/build/bin/clang+0x4a4a726)
#41 0x00000000049fc312 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/disk/llvm/build/bin/clang+0x49fc312)
#42 0x00000000049fc4fb clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/disk/llvm/build/bin/clang+0x49fc4fb)
#43 0x0000000004a11f3e clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/disk/llvm/build/bin/clang+0x4a11f3e)
#44 0x000000000119074f main (/disk/llvm/build/bin/clang+0x119074f)
#45 0x00007f39df78abbb __libc_start_main /build/glibc-G5rUEF/glibc-2.29/csu/../csu/libc-start.c:342:3
#46 0x000000000118f78a _start (/disk/llvm/build/bin/clang+0x118f78a)
clang-11: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 11.0.0 (https://github.com/llvm/llvm-project.git 6990eaf1fe00e9736fbfbcae160e18c5edbcd1d4)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /disk/llvm/build/bin
clang-11: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-11: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/tmp-cf7578.c
clang-11: note: diagnostic msg: /tmp/tmp-cf7578.sh
clang-11: note: diagnostic msg:
********************
Segmentation fault
Sorry, needs OpenMandriva鈥檚
common.config(dump it intokernel/configsthen runmake i386_defconfig common.config) then it should be reproducible.https://github.com/OpenMandrivaAssociation/kernel-release-clang/blob/master/common.config
thanks for the hot tipz, but I still cannot reproduce. I wonder if something covered this back up since yesterday, let me do some bisection.
crashing at f5efa08247c7 (yesterday morning). Bisecting forward.
Just tried TOT right now. Can confirm that it is passing again, so compiler isn't necessarily as haunted as previously indicated. :ghost:
Fixed by @gwelymernans two hours ago https://github.com/llvm/llvm-project/commit/2fe457690da0fc38bc7f9f1d0aee2ba6a6a16ada (without code review...)
Notes to self:
llvm::SplitBlockPredecessors() calls User::replaceUsesOfWith() calls User::setOperand() which is a massive problem for CallBrInst because before we have:
before:
callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@j, %for.end)) #1
to label %cond.true.i [label %for.end]
```
replaceUsesOfWith:
for.end: -> for.end.split.loop.exit:
which produces:
```llvm
callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@j, %for.end)) #1
to label %cond.true.i [label %for.end.split.loop.exit1]
which fails module verification because the indirect label list was updated but not the argument to the asm. We've had this issue in the past, but User::replaceUsesOfWith() is non-virtual (so we can't override it in CallBrInst) and it's lower level than CallBrInst::setSuccessor() or CallBrInst::setIndirectDest(). I feel like I need to write some C++ based unit tests for CallBrInst at this point, because it seems like some basic functionality with it is just broken. And/or we should not materialize the blockaddress parameter to the asm until lowering CallBrInst.
I've posted https://reviews.llvm.org/D74947 to demonstrate some breakage in User::replaceUsesOfWith(). I'm seriously considering adding an assert within it to fire in the presence of a CallBrInst, and running a kernel build to see what other passes are using it and breaking callbrs.
If I remove the assert from llvm::SplitBlockPredecessors and replace the call to Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB); with CallBrInst::SetIndirectDest() (a la https://reviews.llvm.org/D74947?vs=on&id=245785&whitespace=ignore-most#toc), we proceed into the call to UpdateAnalysisInformation which fails an assert splitting the dominator tree node. So I think @gwelymernans fix is correct (though I'm not happy with how it was handled); we're currently unable to split a dominator tree node after splitting a BB terminated by a CallBrInst.
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
[1] %entry {0,7} [0]
[2] %for.cond {1,6} [1]
[3] %cond.true.i {2,3} [2]
[4] %for.end.split.loop.exit {4294967295,4294967295} [3]
[3] %for.end {4,5} [2]
Roots: %entry
This has been fixed in LLVM 11.0.0 and it was picked into LLVM 10.0.0:
https://github.com/llvm/llvm-project/commit/2fe457690da0fc38bc7f9f1d0aee2ba6a6a16ada
https://github.com/llvm/llvm-project/commit/da0fe2ade369223ebea2dafd411746e854a801f2