LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 50888 - ICE on valid code with -O1: llvm::cast(Y*) [with X = llvm::ConstantInt; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::ConstantInt*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Summary: ICE on valid code with -O1: llvm::cast(Y*) [with X = llvm::ConstantInt; Y = l...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-26 13:12 PDT by Chengnian Sun
Modified: 2021-07-21 13:37 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s): f14495dc75d7


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chengnian Sun 2021-06-26 13:12:08 PDT
$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 2e9c75daffddd65e37c3236708b5b133e6f5f2f5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ cat mutant.c
foo() {
  char array[1000];
  __builtin_memset(array, 0, foo);
}

$ clang-trunk -O1 mutant.c
mutant.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
foo() {
^
mutant.c:3:30: warning: incompatible pointer to integer conversion passing 'int ()' to parameter of type 'unsigned long' [-Wint-conversion]
  __builtin_memset(array, 0, foo);
                             ^~~
mutant.c:4:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
clang-13: /tmp/tmp.xjN6dMkdrg-clang-builder/llvm-project/llvm/include/llvm/Support/Casting.h:269: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::ConstantInt; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::ConstantInt*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /scratch/software/clang-trunk/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -main-file-name mutant.c -mrelocation-model static -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210623_080716_0068/delta/perses_result -resource-dir /scratch/software/clang-trunk/lib/clang/13.0.0 -c-isystem . -c-isystem /usr/local/include/cmsith -internal-isystem /scratch/software/clang-trunk/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210623_080716_0068/delta/perses_result -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-368510.o -x c mutant.c
1.	<eof> parser at end of file
2.	Optimizer
 #0 0x0000555e4762d184 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000555e4762a93e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f9d215eb3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #3 0x00007f9d2108a18b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007f9d21069859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
 #5 0x00007f9d21069729 get_sysdep_segment_value /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
 #6 0x00007f9d21069729 _nl_load_domain /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
 #7 0x00007f9d2107af36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x0000555e474b57f7 (/scratch/software/clang-trunk/bin/clang-13+0x37e37f7)
 #9 0x0000555e474be7c4 llvm::sroa::AllocaSliceRewriter::visit((anonymous namespace)::Slice const*) SROA.cpp:0:0
#10 0x0000555e474c323f llvm::SROA::rewritePartition(llvm::AllocaInst&, llvm::sroa::AllocaSlices&, llvm::sroa::Partition&) (/scratch/software/clang-trunk/bin/clang-13+0x37f123f)
#11 0x0000555e474c4d5a llvm::SROA::splitAlloca(llvm::AllocaInst&, llvm::sroa::AllocaSlices&) (.part.0) SROA.cpp:0:0
#12 0x0000555e474c7347 llvm::SROA::runOnAlloca(llvm::AllocaInst&) (/scratch/software/clang-trunk/bin/clang-13+0x37f5347)
#13 0x0000555e474c910d llvm::SROA::runImpl(llvm::Function&, llvm::DominatorTree&, llvm::AssumptionCache&) (/scratch/software/clang-trunk/bin/clang-13+0x37f710d)
#14 0x0000555e474ca1d9 llvm::SROA::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/software/clang-trunk/bin/clang-13+0x37f81d9)
#15 0x0000555e489508f6 llvm::detail::PassModel<llvm::Function, llvm::SROA, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/software/clang-trunk/bin/clang-13+0x4c7e8f6)
#16 0x0000555e46d694d6 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/software/clang-trunk/bin/clang-13+0x30974d6)
#17 0x0000555e451fe836 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/software/clang-trunk/bin/clang-13+0x152c836)
#18 0x0000555e46d67ff9 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/software/clang-trunk/bin/clang-13+0x3095ff9)
#19 0x0000555e451ff0a6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/software/clang-trunk/bin/clang-13+0x152d0a6)
#20 0x0000555e46d658df llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/software/clang-trunk/bin/clang-13+0x30938df)
#21 0x0000555e4795e6ad (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#22 0x0000555e4796192d 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> >) (/scratch/software/clang-trunk/bin/clang-13+0x3c8f92d)
#23 0x0000555e4878ae1f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/software/clang-trunk/bin/clang-13+0x4ab8e1f)
#24 0x0000555e498424d9 clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b704d9)
#25 0x0000555e48789968 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-13+0x4ab7968)
#26 0x0000555e48039599 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-13+0x4367599)
#27 0x0000555e47fcc7e6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-13+0x42fa7e6)
#28 0x0000555e48117480 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-13+0x4445480)
#29 0x0000555e44f37696 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/software/clang-trunk/bin/clang-13+0x1265696)
#30 0x0000555e44f339d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#31 0x0000555e44e610e6 main (/scratch/software/clang-trunk/bin/clang-13+0x118f0e6)
#32 0x00007f9d2106b0b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x0000555e44f3354e _start (/scratch/software/clang-trunk/bin/clang-13+0x126154e)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 2e9c75daffddd65e37c3236708b5b133e6f5f2f5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
clang-13: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/mutant-206b82.c
clang-13: note: diagnostic msg: /tmp/mutant-206b82.sh
clang-13: note: diagnostic msg:

********************
Comment 1 Sanjay Patel 2021-07-21 13:37:43 PDT
https://reviews.llvm.org/rGf14495dc75d7