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

ICE on valid code with -O1: llvm::APFloat::convertToDouble() const: Assertion `getSemantics().isRepresentableBy(semIEEEdouble) && "Float semantics is not representable by IEEEdouble"' failed. #50304

Closed
chengniansun opened this issue Jul 1, 2021 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla

Comments

@chengniansun
Copy link

Bugzilla Link 50960
Resolution FIXED
Resolved on Jul 26, 2021 07:58
Version trunk
OS All
CC @RKSimon,@zygoloid,@rotateright
Fixed by commit(s) 13302c0

Extended Description

clang-trunk -O0 can compile the code successfully.

$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 4aa1c14)
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
double sin(long double) { sin(1.0); }

$ clang-trunk -w -O1 mutant.c
clang-13: /tmp/tmp.M5Z1vtu79t-clang-builder/llvm-project/llvm/lib/Support/APFloat.cpp:4888: double llvm::APFloat::convertToDouble() const: Assertion `getSemantics().isRepresentableBy(semIEEEdouble) && "Float semantics is not representable by IEEEdouble"' 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_20210701_113317_12d2/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 -w -fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210701_113317_12d2/delta/perses_result -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-25a8e9.o -x c mutant.c

  1. parser at end of file
  2. Optimizer
    #​0 0x00005607c54b7264 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
    #​1 0x00005607c54b4a1e SignalHandler(int) Signals.cpp:0:0
    #​2 0x00007f1e5a0453c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
    #​3 0x00007f1e59ae418b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
    #​4 0x00007f1e59ac3859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
    #​5 0x00007f1e59ac3729 get_sysdep_segment_value /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
    #​6 0x00007f1e59ac3729 _nl_load_domain /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
    #​7 0x00007f1e59ad4f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
    #​8 0x00005607c53d166f llvm::APFloat::convertToDouble() const (/scratch/software/clang-trunk/bin/clang-13+0x38a866f)
    #​9 0x00005607c42dbd33 (anonymous namespace)::ConstantFoldFP(double ()(double), llvm::APFloat const&, llvm::Type) ConstantFolding.cpp:0:0
    #​10 0x00005607c42e4305 (anonymous namespace)::ConstantFoldScalarCall1(llvm::StringRef, unsigned int, llvm::Type*, llvm::ArrayRefllvm::Constant*, llvm::TargetLibraryInfo const*, llvm::CallBase const*) ConstantFolding.cpp:0:0
    #​11 0x00005607c42eb269 llvm::ConstantFoldCall(llvm::CallBase const*, llvm::Function*, llvm::ArrayRefllvm::Constant*, llvm::TargetLibraryInfo const*) (/scratch/software/clang-trunk/bin/clang-13+0x27c2269)
    #​12 0x00005607c4346066 llvm::SimplifyCall(llvm::CallBase*, llvm::SimplifyQuery const&) (/scratch/software/clang-trunk/bin/clang-13+0x281d066)
    #​13 0x00005607c434c25d llvm::SimplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&, llvm::OptimizationRemarkEmitter*) (/scratch/software/clang-trunk/bin/clang-13+0x282325d)
    #​14 0x00005607c515736c (anonymous namespace)::EarlyCSE::processNode(llvm::DomTreeNodeBasellvm::BasicBlock) EarlyCSE.cpp:0:0
    #​15 0x00005607c5158dd4 (anonymous namespace)::EarlyCSE::run() EarlyCSE.cpp:0:0
    #​16 0x00005607c5159e23 llvm::EarlyCSEPass::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/scratch/software/clang-trunk/bin/clang-13+0x3630e23)
    #​17 0x00005607c57de296 llvm::detail::PassModel<llvm::Function, llvm::EarlyCSEPass, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/scratch/software/clang-trunk/bin/clang-13+0x3cb5296)
    #​18 0x00005607c4bee6f6 llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/scratch/software/clang-trunk/bin/clang-13+0x30c56f6)
    #​19 0x00005607c306a7b6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function >, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function >::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/scratch/software/clang-trunk/bin/clang-13+0x15417b6)
    #​20 0x00005607c4bed219 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/scratch/software/clang-trunk/bin/clang-13+0x30c4219)
    #​21 0x00005607c306b026 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/scratch/software/clang-trunk/bin/clang-13+0x1542026)
    #​22 0x00005607c4beaaff llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module >::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/scratch/software/clang-trunk/bin/clang-13+0x30c1aff)
    #​23 0x00005607c57ee11d (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >) BackendUtil.cpp:0:0
    #​24 0x00005607c57f139d 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 >) (/scratch/software/clang-trunk/bin/clang-13+0x3cc839d)
    #​25 0x00005607c6624dbf clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/software/clang-trunk/bin/clang-13+0x4afbdbf)
    #​26 0x00005607c76dc6f9 clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5bb36f9)
    #​27 0x00005607c6623908 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-13+0x4afa908)
    #​28 0x00005607c5ec9d99 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-13+0x43a0d99)
    #​29 0x00005607c5e5cdb6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-13+0x4333db6)
    #​30 0x00005607c5fa7a80 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-13+0x447ea80)
    #​31 0x00005607c2da0946 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/software/clang-trunk/bin/clang-13+0x1277946)
    #​32 0x00005607c2d9cc88 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
    #​33 0x00005607c2cca0d6 main (/scratch/software/clang-trunk/bin/clang-13+0x11a10d6)
    #​34 0x00007f1e59ac50b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
    #​35 0x00005607c2d9c7fe _start (/scratch/software/clang-trunk/bin/clang-13+0x12737fe)
    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 4aa1c14)
    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-2b7809.c
clang-13: note: diagnostic msg: /tmp/mutant-2b7809.sh
clang-13: note: diagnostic msg:


@chengniansun
Copy link
Author

assigned to @rotateright

@rotateright
Copy link
Contributor

The root problem is that the "sin" in this code is not the math library call that we thought it was -- the return type doesn't match the argument type.

The recursion and lack of 'return' may have helped bypass some other analysis, but I can reduce this to crash with just -instsimplify (we don't have a wrapper optimization pass for constant folding alone anymore).

@rotateright
Copy link
Contributor

@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