Issue |
138944
|
Summary |
Assertion Failure: "Operand is DELETED_NODE!" exposed after llvm19 upstream commit cbb0477e9a8d
|
Labels |
new issue
|
Assignees |
|
Reporter |
wjristow
|
We've had a compile-time crash reported to us, happening with optimization, fast-math, and FMA (`-O1 -ffast-math -mfma`), which we've bisected to llvmorg-19-init-9453-gcbb0477e9a8d.
I'm not sure if there is a problem in that commit directly, or if it's exposing a latent problem. Specifically, in investigating, my colleague @OCHyams noticed that an older commit (llvmorg-16-init-15033-g6161a8dd5c5a) appears to be related. Reverting the change of that older commit avoids the crash.
Here is the reduced test-case, which fails in llvm19, llvm20 and trunk:
```
typedef float __m128 __attribute__((__vector_size__(16)));
typedef int __v4si __attribute__((__vector_size__(16)));
__m128 x1, x2, x3, x4;
struct Container {
__m128 f;
};
class fVec {
public:
Container mData;
fVec(const __m128 &);
fVec operator-() const;
};
void consume(fVec);
fVec::fVec(const __m128 &m) { mData.f = m; }
fVec fVec::operator-() const {
__m128 k = -mData.f;
return k;
}
fVec process(fVec m) {
__m128 t1, t2, t3, t4;
x4 = __builtin_ia32_rcpps(m.mData.f);
x3 = __builtin_ia32_cmpneqps(x1, x2);
t1 = m.mData.f * x4;
t2 = x4 + x4;
t3 = (__v4si)t1 & (__v4si)x3;
t4 = t2 - t3;
return t4;
}
void foo(fVec vIn) {
fVec v1 = -vIn;
fVec v2 = process(v1);
consume(v2);
}
```
Compiling this with a compiler that includes llvmorg-19-init-9453-gcbb0477e9a8d, with the switches `-O1 -ffast-math -mfma` ([godbolt link](https://godbolt.org/z/vqbdGGdvf)), gets the following crash:
```
clang++: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7791: llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, const llvm::SDLoc&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags): Assertion `N1.getOpcode() != ISD::DELETED_NODE && N2.getOpcode() != ISD::DELETED_NODE && N3.getOpcode() != ISD::DELETED_NODE && "Operand is DELETED_NODE!"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O1 -ffast-math -mfma <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z3foo4fVec'
#0 0x0000000003f76d78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f76d78)
#1 0x0000000003f74a04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f74a04)
#2 0x0000000003eb98c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072e7f1c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072e7f1c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072e7f1c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072e7f1c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072e7f1c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072e7f1c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000052cd595 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52cd595)
#10 0x00000000052bff72 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::ArrayRef<llvm::SDValue>, llvm::SDNodeFlags) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52bff72)
#11 0x0000000002b95deb llvm::X86TargetLowering::getNegatedExpression(llvm::SDValue, llvm::SelectionDAG&, bool, bool, llvm::TargetLoweringBase::NegatibleCost&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2b95deb)
#12 0x000000000510cd2f llvm::TargetLowering::getCheaperOrNeutralNegatedExpression(llvm::SDValue, llvm::SelectionDAG&, bool, bool, llvm::TargetLoweringBase::NegatibleCost, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x510cd2f)
#13 0x00000000051214a1 llvm::SDValue (anonymous namespace)::DAGCombiner::visitFMA<llvm::EmptyMatchContext>(llvm::SDNode*) DAGCombiner.cpp:0:0
#14 0x00000000051bbe90 (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*) DAGCombiner.cpp:0:0
#15 0x00000000051bd31c (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#16 0x00000000051bec58 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#17 0x00000000051c150b llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51c150b)
#18 0x0000000005300e75 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5300e75)
#19 0x0000000005304025 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5304025)
#20 0x00000000053052e5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53052e5)
#21 0x00000000052f5cff llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52f5cff)
#22 0x000000000329e06a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#23 0x00000000038c12cf llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c12cf)
#24 0x00000000038c1681 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c1681)
#25 0x00000000038c1f21 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c1f21)
#26 0x000000000422ed5e clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x422ed5e)
#27 0x0000000004918b90 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4918b90)
#28 0x00000000065e9acc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65e9acc)
#29 0x0000000004918f78 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4918f78)
#30 0x0000000004c0c235 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c0c235)
#31 0x0000000004b8b83e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b8b83e)
#32 0x0000000004d000e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d000e9)
#33 0x0000000000da766f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda766f)
#34 0x0000000000d9d83a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x000000000497f839 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#36 0x0000000003eb9d64 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eb9d64)
#37 0x000000000497fe4f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#38 0x000000000494229d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x494229d)
#39 0x000000000494332e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x494332e)
#40 0x000000000494b185 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x494b185)
#41 0x0000000000da35d8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda35d8)
#42 0x0000000000c28a64 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc28a64)
#43 0x000072e7f1c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x000072e7f1c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000d9d2e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9d2e5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs