llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.44k stars 12.16k forks source link

[X86][m32][_Float128] Float128 + m32 + frounding-math produce ICE #101984

Open zhangtianhao6 opened 4 months ago

zhangtianhao6 commented 4 months ago

t.c

typedef __float128 _Float128;
typedef unsigned long int mp_limb_t;
typedef long int mp_size_t;
__extension__ typedef long long int intmax_t;
static _Float128
round_and_return (mp_limb_t *retval, intmax_t exponent, int negative,
    mp_limb_t round_limb, mp_size_t round_bit, int more_bits)
{
# 309 "../stdlib/strtod_l.c"
   _Float128 force_underflow = 3.36210314311209350626267781732175260e-4932q * 3.36210314311209350626267781732175260e-4932q;
   do { if (sizeof (force_underflow) <= sizeof (double) || __builtin_types_compatible_p (__typeof (force_underflow), _Float128)) __asm __volatile ("" : : "x" (force_underflow)); else __asm __volatile ("" : : "f" (force_underflow)); } while (0);
# 357 "../stdlib/strtod_l.c"
}
# 506 "../stdlib/strtod_l.c"
_Float128
____STRTOF_INTERNAL (const char *nptr, char **endptr, int group)
{
mp_limb_t retval[(((113) + ((32) - 1)) / (32))];
 int negative;
intmax_t exponent;
return round_and_return (retval, exponent, negative, 0, 0, 0);

}
clang -m32 -frounding-math

ICE

fatal error: error in backend: Do not know how to soften this operator's operand!
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-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 -m32 -frounding-math <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 '@round_and_return'
 #0 0x000000000382fe38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382fe38)
 #1 0x000000000382dfa4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382dfa4)
 #2 0x0000000003778bb3 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3778bb3)
 #3 0x000000000382577e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382577e)
 #4 0x0000000000c9ab56 (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9ab56)
 #5 0x0000000003782c13 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3782c13)
 #6 0x0000000003782d78 (/opt/compiler-explorer/clang-trunk/bin/clang+0x3782d78)
 #7 0x0000000004b34b60 llvm::DAGTypeLegalizer::SoftenFloatRes_SELECT(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4b34b60)
 #8 0x0000000004a9cfeb llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a9cfeb)
 #9 0x0000000004a9d441 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a9d441)
#10 0x0000000004a18e72 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a18e72)
#11 0x0000000004a1be62 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a1be62)
#12 0x0000000004a1d6cf llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a1d6cf)
#13 0x0000000004a0cda1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a0cda1)
#14 0x0000000002c768fb llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x00000000031c3462 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c3462)
#16 0x00000000031c3721 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c3721)
#17 0x00000000031c29ab llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c29ab)
#18 0x0000000003acae81 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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-trunk/bin/clang+0x3acae81)
#19 0x0000000004107624 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4107624)
#20 0x00000000060a0fdc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x60a0fdc)
#21 0x0000000004107db5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4107db5)
#22 0x00000000043adbd1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x43adbd1)
#23 0x000000000433097b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x433097b)
#24 0x0000000004494ba3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4494ba3)
#25 0x0000000000c9ca9c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9ca9c)
#26 0x0000000000c969dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x00000000041510c9 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
#28 0x0000000003778ab3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3778ab3)
#29 0x00000000041512e9 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
#30 0x0000000004116e37 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x4116e37)
#31 0x00000000041177ed clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x41177ed)
#32 0x000000000412123c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x412123c)
#33 0x0000000000c99d81 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xc99d81)
#34 0x0000000000b6ffc4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xb6ffc4)
#35 0x00007e0ab0429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007e0ab0429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000c9647e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9647e)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70

This error occurs when compiling m32 glibc. GCC is ok. https://godbolt.org/z/9WqanPhv6

llvmbot commented 4 months ago

@llvm/issue-subscribers-backend-x86

Author: None (zhangtianhao6)

t.c ``` typedef __float128 _Float128; typedef unsigned long int mp_limb_t; typedef long int mp_size_t; __extension__ typedef long long int intmax_t; static _Float128 round_and_return (mp_limb_t *retval, intmax_t exponent, int negative, mp_limb_t round_limb, mp_size_t round_bit, int more_bits) { # 309 "../stdlib/strtod_l.c" _Float128 force_underflow = 3.36210314311209350626267781732175260e-4932q * 3.36210314311209350626267781732175260e-4932q; do { if (sizeof (force_underflow) <= sizeof (double) || __builtin_types_compatible_p (__typeof (force_underflow), _Float128)) __asm __volatile ("" : : "x" (force_underflow)); else __asm __volatile ("" : : "f" (force_underflow)); } while (0); # 357 "../stdlib/strtod_l.c" } # 506 "../stdlib/strtod_l.c" _Float128 ____STRTOF_INTERNAL (const char *nptr, char **endptr, int group) { mp_limb_t retval[(((113) + ((32) - 1)) / (32))]; int negative; intmax_t exponent; return round_and_return (retval, exponent, negative, 0, 0, 0); } ``` ``` clang -m32 -frounding-math ``` ICE ``` fatal error: error in backend: Do not know how to soften this operator's operand! 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-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 -m32 -frounding-math <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 '@round_and_return' #0 0x000000000382fe38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382fe38) #1 0x000000000382dfa4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382dfa4) #2 0x0000000003778bb3 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3778bb3) #3 0x000000000382577e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x382577e) #4 0x0000000000c9ab56 (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9ab56) #5 0x0000000003782c13 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3782c13) #6 0x0000000003782d78 (/opt/compiler-explorer/clang-trunk/bin/clang+0x3782d78) #7 0x0000000004b34b60 llvm::DAGTypeLegalizer::SoftenFloatRes_SELECT(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4b34b60) #8 0x0000000004a9cfeb llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a9cfeb) #9 0x0000000004a9d441 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a9d441) #10 0x0000000004a18e72 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a18e72) #11 0x0000000004a1be62 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a1be62) #12 0x0000000004a1d6cf llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a1d6cf) #13 0x0000000004a0cda1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a0cda1) #14 0x0000000002c768fb llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #15 0x00000000031c3462 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c3462) #16 0x00000000031c3721 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c3721) #17 0x00000000031c29ab llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x31c29ab) #18 0x0000000003acae81 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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-trunk/bin/clang+0x3acae81) #19 0x0000000004107624 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4107624) #20 0x00000000060a0fdc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x60a0fdc) #21 0x0000000004107db5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4107db5) #22 0x00000000043adbd1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x43adbd1) #23 0x000000000433097b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x433097b) #24 0x0000000004494ba3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4494ba3) #25 0x0000000000c9ca9c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9ca9c) #26 0x0000000000c969dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #27 0x00000000041510c9 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 #28 0x0000000003778ab3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3778ab3) #29 0x00000000041512e9 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 #30 0x0000000004116e37 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x4116e37) #31 0x00000000041177ed clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x41177ed) #32 0x000000000412123c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x412123c) #33 0x0000000000c99d81 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xc99d81) #34 0x0000000000b6ffc4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xb6ffc4) #35 0x00007e0ab0429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90) #36 0x00007e0ab0429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40) #37 0x0000000000c9647e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xc9647e) clang: error: clang frontend command failed with exit code 70 (use -v to see invocation) Compiler returned: 70 ``` This error occurs when compiling m32 glibc. GCC is ok. https://godbolt.org/z/9WqanPhv6