Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stackmaps] Passing live i128 constant with value greater than 2^{63} -1 crashes LLVM #55609

Open
vext01 opened this issue May 20, 2022 · 2 comments

Comments

@vext01
Copy link
Contributor

vext01 commented May 20, 2022

This works:

declare void @llvm.experimental.stackmap(i64, i32, ...)

define dso_local i32 @main(i32 %argc, i8** %argv) {
entry:
  %x = zext i32 %argc to i128
  call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0, i128 9223372036854775807) ; <-- 2**63-1
  ret i32 0
}

This doesn't:

declare void @llvm.experimental.stackmap(i64, i32, ...)

define dso_local i32 @main(i32 %argc, i8** %argv) {
entry:
  %x = zext i32 %argc to i128
  call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0, i128 9223372036854775808) ; <-- 2**63
  ret i32 0
}

Gives:

$ clang -O2 i128.ll
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
clang-15: /home/vext01/research/llvm-project/llvm/include/llvm/ADT/APInt.h:1493: int64_t llvm::APInt::getSExtValue() const: Assertion `getSignificantBits() <= 64 && "Too many bits for int64_t"' 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: /home/vext01/research/llvm-project/build/bin/clang-15 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name i128.ll -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/vext01/research/llvm-project -resource-dir /home/vext01/research/llvm-project/build/lib/clang/15.0.0 -O2 -fdebug-compilation-dir=/home/vext01/research/llvm-project -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/i128-c5f403.o -x ir i128.ll
1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'i128.ll'.
3.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
 #0 0x0000556befbcce10 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000556befbca65c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fcbba840140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #3 0x00007fcbba323ce1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007fcbba30d537 abort ./stdlib/abort.c:81:7
 #5 0x00007fcbba30d40f get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
 #6 0x00007fcbba30d40f _nl_load_domain ./intl/loadmsgcat.c:970:34
 #7 0x00007fcbba31c662 (/lib/x86_64-linux-gnu/libc.so.6+0x34662)
 #8 0x0000556bf0b94aa2 addStackMapLiveVars(llvm::CallBase const&, unsigned int, llvm::SDLoc const&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::SelectionDAGBuilder&) SelectionDAGBuilder.cpp:0:0
 #9 0x0000556bf0b94dc7 llvm::SelectionDAGBuilder::visitStackmap(llvm::CallInst const&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4b93dc7)
#10 0x0000556bf0b8550b llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4b8450b)
#11 0x0000556bf0bbaccb llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4bb9ccb)
#12 0x0000556bf0c32b89 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4c31b89)
#13 0x0000556bf0c33d17 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4c32d17)
#14 0x0000556bf0c35ce9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#15 0x0000556bee59289c (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#16 0x0000556beed37d70 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x2d36d70)
#17 0x0000556bef25e734 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x325d734)
#18 0x0000556bef25e951 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x325d951)
#19 0x0000556bef25f5e5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x325e5e5)
#20 0x0000556beff6515b 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>>) (/home/vext01/research/llvm-project/build/bin/clang-15+0x3f6415b)
#21 0x0000556bf0d7bb82 clang::CodeGenAction::ExecuteAction() (/home/vext01/research/llvm-project/build/bin/clang-15+0x4d7ab82)
#22 0x0000556bf067d829 clang::FrontendAction::Execute() (/home/vext01/research/llvm-project/build/bin/clang-15+0x467c829)
#23 0x0000556bf0607336 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4606336)
#24 0x0000556bf0733458 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/vext01/research/llvm-project/build/bin/clang-15+0x4732458)
#25 0x0000556bed2169da cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/vext01/research/llvm-project/build/bin/clang-15+0x12159da)
#26 0x0000556bed212264 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000556bed166fea main (/home/vext01/research/llvm-project/build/bin/clang-15+0x1165fea)
#28 0x00007fcbba30ed0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#29 0x0000556bed211c0a _start (/home/vext01/research/llvm-project/build/bin/clang-15+0x1210c0a)
clang-15: error: unable to execute command: Aborted
clang-15: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 15.0.0 (https://github.com/llvm/llvm-project f94a4476791873a4af1986abcd13c18991a599ee)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/vext01/research/llvm-project/build/bin
clang-15: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

The stackmap code assumes that the constant can be built with DAG.getTargetConstant(int64_t Val, ...)

@vext01 vext01 changed the title [stackmaps] Passing live i128 constant with value greater than 2^{31} -1 crashes LLVM [stackmaps] Passing live i128 constant with value greater than 2^{63} -1 crashes LLVM May 20, 2022
@xgupta
Copy link
Contributor

xgupta commented Jan 24, 2023

seems to fixed on trunk - https://godbolt.org/z/qn7xoeqa7.

@xgupta xgupta closed this as completed Jan 24, 2023
@xgupta
Copy link
Contributor

xgupta commented Jan 24, 2023

sorry, It is still an issue, I haven't used assert llc -https://godbolt.org/z/nMKPGEh6z.

@xgupta xgupta reopened this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants