Issue |
131389
|
Summary |
[X86] fverbose-asm: Assertion `(BitWidth % EltBits) == 0 && "Element size mismatch"' failed.
|
Labels |
new issue
|
Assignees |
|
Reporter |
hvdijk
|
Please consider the following reduced LLVM IR test, courtesy of `llvm-reduce`:
```llvm
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0
define <2 x float> @foo(<2 x float> %0) {
entry:
%1 = extractelement <2 x float> %0, i64 0
%2 = tail call float @llvm.fabs.f32(float %1)
%3 = insertelement <2 x float> zeroinitializer, float %2, i64 0
%4 = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> %3, i32 1)
%5 = select <2 x i1> %4, <2 x float> splat (float 1.000000e+00), <2 x float> zeroinitializer
ret <2 x float> %5
}
define void @bar(ptr %0, ptr %1) {
entry:
%2 = alloca [6 x float], align 8
%3 = getelementptr i8, ptr %2, i64 8
store float 0.000000e+00, ptr %3, align 8
%4 = getelementptr i8, ptr %2, i64 12
store float 0.000000e+00, ptr %4, align 4
%5 = getelementptr i8, ptr %2, i64 16
store float 1.000000e+00, ptr %5, align 8
%6 = getelementptr i8, ptr %2, i64 20
store float 0.000000e+00, ptr %6, align 4
%7 = load <4 x float>, ptr %2, align 8
%8 = shufflevector <4 x float> %7, <4 x float> zeroinitializer, <2 x i32> <i32 0, i32 1>
%9 = call <2 x float> @foo(<2 x float> %8)
%10 = load <4 x float>, ptr %3, align 8
%11 = extractelement <2 x float> %9, i64 0
store float %11, ptr %1, align 4
%12 = extractelement <4 x float> %10, i64 2
store float %12, ptr %0, align 4
ret void
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i1> @llvm.is.fpclass.v2f32(<2 x float>, i32 immarg) #0
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
```
Compiling this with `clang -O3 -S -o - bug.ll -fno-verbose-asm` works. With `-fverbose-asm`, however, it results in:
```
clang: /home/harald/llvm-project/main/llvm/lib/Target/X86/X86MCInstLower.cpp:1585: void printConstant(const llvm::Constant*, unsigned int, llvm::raw_ostream&, bool): Assertion `(BitWidth % EltBits) == 0 && "Element size mismatch"' 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: bin/clang -S -O3 -o /dev/null /home/harald/bug/bug.ll -fverbose-asm
1. Code generation
2. Running pass 'Function Pass Manager' on module '/home/harald/bug/bug.ll'.
3. Running pass 'X86 Assembly Printer' on function '@bar'
#0 0x00007f4b8466ad14 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/harald/llvm-project/main/llvm/lib/Support/Unix/Signals.inc:804:22
#1 0x00007f4b8466b12b PrintStackTraceSignalHandler(void*) /home/harald/llvm-project/main/llvm/lib/Support/Unix/Signals.inc:880:1
#2 0x00007f4b84668555 llvm::sys::RunSignalHandlers() /home/harald/llvm-project/main/llvm/lib/Support/Signals.cpp:105:20
#3 0x00007f4b8466a446 llvm::sys::CleanupOnSignal(unsigned long) /home/harald/llvm-project/main/llvm/lib/Support/Unix/Signals.inc:369:31
#4 0x00007f4b844f47de (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/harald/llvm-project/main/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
#5 0x00007f4b844f4d0a CrashRecoverySignalHandler(int) /home/harald/llvm-project/main/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
#6 0x00007f4b82645250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
#7 0x00007f4b826a3f1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#8 0x00007f4b826a3f1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#9 0x00007f4b826a3f1c pthread_kill ./nptl/pthread_kill.c:89:10
#10 0x00007f4b8264519e raise ./signal/../sysdeps/posix/raise.c:27:6
#11 0x00007f4b82628902 abort ./stdlib/abort.c:81:7
#12 0x00007f4b8262881e _nl_load_domain ./intl/loadmsgcat.c:1177:9
#13 0x00007f4b8263b7c7 (/lib/x86_64-linux-gnu/libc.so.6+0x3b7c7)
#14 0x00007f4b8b7b5c9d printConstant(llvm::Constant const*, unsigned int, llvm::raw_ostream&, bool) /home/harald/llvm-project/main/llvm/lib/Target/X86/X86MCInstLower.cpp:1586:0
#15 0x00007f4b8b7b5fd4 printZeroUpperMove(llvm::MachineInstr const*, llvm::MCStreamer&, int, int, char const*) /home/harald/llvm-project/main/llvm/lib/Target/X86/X86MCInstLower.cpp:1623:0
#16 0x00007f4b8b7b8999 addConstantComments(llvm::MachineInstr const*, llvm::MCStreamer&) /home/harald/llvm-project/main/llvm/lib/Target/X86/X86MCInstLower.cpp:2007:0
#17 0x00007f4b8b7b901f llvm::X86AsmPrinter::emitInstruction(llvm::MachineInstr const*) /home/harald/llvm-project/main/llvm/lib/Target/X86/X86MCInstLower.cpp:2217:0
#18 0x00007f4b85b7061e llvm::AsmPrinter::emitFunctionBody() /home/harald/llvm-project/main/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1936:9
#19 0x00007f4b8b3b1ad8 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) /home/harald/llvm-project/main/llvm/lib/Target/X86/X86AsmPrinter.cpp:91:0
#20 0x00007f4b850e48f5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/harald/llvm-project/main/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:30
#21 0x00007f4b849f7f0e llvm::FPPassManager::runOnFunction(llvm::Function&) /home/harald/llvm-project/main/llvm/lib/IR/LegacyPassManager.cpp:1406:20
#22 0x00007f4b849f81e4 llvm::FPPassManager::runOnModule(llvm::Module&) /home/harald/llvm-project/main/llvm/lib/IR/LegacyPassManager.cpp:1452:13
#23 0x00007f4b849f863c (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/harald/llvm-project/main/llvm/lib/IR/LegacyPassManager.cpp:1521:20
#24 0x00007f4b849f35c5 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/harald/llvm-project/main/llvm/lib/IR/LegacyPassManager.cpp:539:13
#25 0x00007f4b849f8f33 llvm::legacy::PassManager::run(llvm::Module&) /home/harald/llvm-project/main/llvm/lib/IR/LegacyPassManager.cpp:1649:1
#26 0x00007f4b9828b8fe (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /home/harald/llvm-project/main/clang/lib/CodeGen/BackendUtil.cpp:1245:9
#27 0x00007f4b9828bb2b (anonymous namespace)::EmitAssemblyHelper::emitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) /home/harald/llvm-project/main/clang/lib/CodeGen/BackendUtil.cpp:1270:7
#28 0x00007f4b9828ccf8 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*) /home/harald/llvm-project/main/clang/lib/CodeGen/BackendUtil.cpp:1433:25
#29 0x00007f4b98bde6f4 clang::CodeGenAction::ExecuteAction() /home/harald/llvm-project/main/clang/lib/CodeGen/CodeGenAction.cpp:1177:20
#30 0x00007f4b99a025ff clang::FrontendAction::Execute() /home/harald/llvm-project/main/clang/lib/Frontend/FrontendAction.cpp:1076:38
#31 0x00007f4b99924709 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/harald/llvm-project/main/clang/lib/Frontend/CompilerInstance.cpp:1056:42
#32 0x00007f4b99b06cb1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/harald/llvm-project/main/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:38
#33 0x000056e979f2f637 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/harald/llvm-project/main/clang/tools/driver/cc1_main.cpp:294:40
#34 0x000056e979f1fd84 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/harald/llvm-project/main/clang/tools/driver/driver.cpp:218:20
#35 0x000056e979f1ffa0 clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)::operator()(llvm::SmallVectorImpl<char const*>&) const /home/harald/llvm-project/main/clang/tools/driver/driver.cpp:365:7
#36 0x000056e979f21689 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) /home/harald/llvm-project/main/llvm/include/llvm/ADT/STLFunctionalExtras.h:48:3
#37 0x00007f4b993c450b llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /home/harald/llvm-project/main/llvm/include/llvm/ADT/STLFunctionalExtras.h:70:3
#38 0x00007f4b993c2e28 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'()::operator()() const /home/harald/llvm-project/main/clang/lib/Driver/Job.cpp:437:32
#39 0x00007f4b993c32ea 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) /home/harald/llvm-project/main/llvm/include/llvm/ADT/STLFunctionalExtras.h:47:40
#40 0x00007f4b844de236 llvm::function_ref<void ()>::operator()() const /home/harald/llvm-project/main/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:62
#41 0x00007f4b844f4f2c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/harald/llvm-project/main/llvm/lib/Support/CrashRecoveryContext.cpp:427:10
#42 0x00007f4b993c304d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /home/harald/llvm-project/main/clang/lib/Driver/Job.cpp:437:7
#43 0x00007f4b9934fe87 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /home/harald/llvm-project/main/clang/lib/Driver/Compilation.cpp:196:22
#44 0x00007f4b9935022a clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /home/harald/llvm-project/main/clang/lib/Driver/Compilation.cpp:251:62
#45 0x00007f4b99368c00 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /home/harald/llvm-project/main/clang/lib/Driver/Driver.cpp:2232:28
#46 0x000056e979f211d2 clang_main(int, char**, llvm::ToolContext const&) /home/harald/llvm-project/main/clang/tools/driver/driver.cpp:402:39
#47 0x000056e979f565b6 main /home/harald/llvm-project/main/build/x86_64-linux-debug/tools/clang/tools/driver/clang-driver.cpp:17:20
#48 0x00007f4b8262a3b8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#49 0x00007f4b8262a47b call_init ./csu/../csu/libc-start.c:128:20
#50 0x00007f4b8262a47b __libc_start_main ./csu/../csu/libc-start.c:347:5
#51 0x000056e979f1f0c5 _start (bin/clang+0x150c5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 21.0.0git (https://github.com/llvm/llvm-project 8437b7f5584765ad4f7885500647657714930fbb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/harald/llvm-project/main/build/x86_64-linux-debug/bin
Build config: +unoptimized, +assertions
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
```
I tried digging in, it seems to come from `-fverbose-asm` printing values of constant pool constants, but here, optimisations have combined two `float` values into one `double` value and the instruction operand printing does not seem to be able to handle that. But I am not sure what assumptions are valid, so I am not sure whether the fault is in the instruction printing, or whether the fault is in the instruction generation (where it should use a constant of a different type).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs