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

Crash on -O3: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::Instruction; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::Instruction*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' #50895

Closed
haoxintu opened this issue Aug 20, 2021 · 1 comment
Labels
bugzilla Issues migrated from bugzilla

Comments

@haoxintu
Copy link

Bugzilla Link 51553
Resolution FIXED
Resolved on Aug 20, 2021 11:54
Version trunk
OS Linux
CC @rotateright

Extended Description

Hi all.

This valid code makes the trunk clang crash at -O3.

$cat small.c
#include <stdint.h>
int a;
volatile uint64_t b;
c() {
int16_t *d = a;
for (;;) {
uint8_t e;
volatile int f = ((*d = 40780) / (e = f) ? 0 : b) >> 4;
}
}

$clang -w -O3 small.c
clang-14: /home/haoxin/haoxin-data/compilers/llvm-project/llvm/include/llvm/Support/Casting.h:269: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::Instruction; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::Instruction*]: Assertion `isa(Val) && "cast() 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: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -main-file-name small.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=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/reduce -resource-dir /home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0 -internal-isystem /home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -w -fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/reduce -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-38757f.o -x c small.c

  1.  <eof> parser at end of file
    
  2.  Optimizer
    

#​0 0x000055f61ea17514 PrintStackTraceSignalHandler(void*) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3b17514)
#​1 0x000055f61ea14c2e SignalHandler(int) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3b14c2e)
#​2 0x00007fd8c4e3e3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#​3 0x00007fd8c48dd18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#​4 0x00007fd8c48bc859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#​5 0x00007fd8c48bc729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#​6 0x00007fd8c48bc729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#​7 0x00007fd8c48cdf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#​8 0x000055f61e34c021 llvm::TruncInstCombine::ReduceExpressionDag(llvm::Type*) (.localalias) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x344c021)
#​9 0x000055f61e34f2c7 llvm::TruncInstCombine::run(llvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x344f2c7)
#​10 0x000055f61e34935a runImpl(llvm::Function&, llvm::TargetLibraryInfo&, llvm::DominatorTree&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x344935a)
#​11 0x000055f61e34a2fb llvm::AggressiveInstCombinePass::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x344a2fb)
#​12 0x000055f61fc27e56 llvm::detail::PassModel<llvm::Function, llvm::AggressiveInstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4d27e56)
#​13 0x000055f61e10cf36 llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x320cf36)
#​14 0x000055f61c50ecf6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function >, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x160ecf6)
#​15 0x000055f61d7c6f1f llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x28c6f1f)
#​16 0x000055f61c50fa46 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x160fa46)
#​17 0x000055f61d7be48b llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x28be48b)
#​18 0x000055f61e232cf6 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3332cf6)
#​19 0x000055f61d7c2b04 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x28c2b04)
#​20 0x000055f61e232ca6 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3332ca6)
#​21 0x000055f61d7c07f3 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x28c07f3)
#​22 0x000055f61e232d46 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3332d46)
#​23 0x000055f61e10933f llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x320933f)
#​24 0x000055f61e235227 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3335227)
#​25 0x000055f61fc29ed6 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4d29ed6)
#​26 0x000055f61e10933f llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x320933f)
#​27 0x000055f61ed59d0c (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3e59d0c)
#​28 0x000055f61ed5cf7d 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_deletellvm::raw_pwrite_stream >) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3e5cf7d)
#​29 0x000055f61fbbffff clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4cbffff)
#​30 0x000055f62092b269 clang::ParseAST(clang::Sema&, bool, bool) (.localalias) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x5a2b269)
#​31 0x000055f61fbbeb48 clang::CodeGenAction::ExecuteAction() (.localalias) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4cbeb48)
#​32 0x000055f61f453349 clang::FrontendAction::Execute() (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4553349)
#​33 0x000055f61f3e8a5e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (.localalias) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x44e8a5e)
#​34 0x000055f61f5324b0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x46324b0)
#​35 0x000055f61c22e25d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x132e25d)
#​36 0x000055f61c22a5a8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x132a5a8)
#​37 0x000055f61c15fa99 main (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x125fa99)
#​38 0x00007fd8c48be0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#​39 0x000055f61c22a11e _start (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x132a11e)
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project 765a421)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
clang-14: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/small-43d552.c
clang-14: note: diagnostic msg: /tmp/small-43d552.sh
clang-14: note: diagnostic msg:


Thanks,
Haoxin

@rotateright
Copy link
Contributor

This bug was introduced with:
https://reviews.llvm.org/rGcfb6dfcbd13b417f83d8a

There was a similar report posted after commit in:
https://reviews.llvm.org/D108201

Should be fixed with:
https://reviews.llvm.org/rGdd19f342fa21

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants