[llvm-bugs] [Bug 37811] New: clang crashes on valid code at -O1 and above: Unexpected Binary operation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 14 19:27:22 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37811

            Bug ID: 37811
           Summary: clang crashes on valid code at -O1 and above:
                    Unexpected Binary operation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org

$ clang-trunk -v
clang version 7.0.0 (trunk 334695)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin


$ clang-trunk -O1 abc.c
abc.c:16:7: warning: incompatible pointer types assigning to 'short *' from
'long *' [-Wincompatible-pointer-types]
    g = &f;
      ^ ~~
abc.c:12:5: warning: expression result unused [-Wunused-value]
    (0xB43AD2C2 % 0 | 5) / (f *= e) ?: (e = f);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
abc.c:15:9: warning: expression result unused [-Wunused-value]
    b ? *g : 0;
        ^~
abc.c:12:17: warning: remainder by zero is undefined [-Wdivision-by-zero]
    (0xB43AD2C2 % 0 | 5) / (f *= e) ?: (e = f);
                ^ ~
Unexpected Binary operation
UNREACHABLE executed at
/home/absozero/trunk/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:3871!
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-7 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir
/home/absozero/trunk/root-clang/lib/clang/7.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/7.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 156 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/abc-b1b81c.o -x c abc.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Function Pass Manager' on module 'abc.c'.
4.      Running pass 'Combine redundant instructions' on function '@fn1'
#0 0x000000000207c684 PrintStackTraceSignalHandler(void*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x207c684)
#1 0x000000000207a5de llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-7+0x207a5de)
#2 0x000000000207c842 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-7+0x207c842)
#3 0x00007fb625763330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fb62433ec37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fb624342028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#6 0x000000000202e5e6 (/home/absozero/trunk/root-clang/bin/clang-7+0x202e5e6)
#7 0x0000000001ce32d9 processUMulZExtIdiom(llvm::ICmpInst&, llvm::Value*,
llvm::Value*, llvm::InstCombiner&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1ce32d9)
#8 0x0000000001ce1f8b llvm::InstCombiner::visitICmpInst(llvm::ICmpInst&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1ce1f8b)
#9 0x0000000001c7ab7d llvm::InstCombiner::run()
(/home/absozero/trunk/root-clang/bin/clang-7+0x1c7ab7d)
#10 0x0000000001c7cc71 combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&,
llvm::OptimizationRemarkEmitter&, bool, llvm::LoopInfo*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1c7cc71)
#11 0x0000000001c7d32a
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1c7d32a)
#12 0x0000000001b4bc56 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1b4bc56)
#13 0x0000000001b4bf23 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1b4bf23)
#14 0x0000000001b4c480 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1b4c480)
#15 0x00000000022418c9 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/absozero/trunk/root-clang/bin/clang-7+0x22418c9)
#16 0x0000000002b6b170
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x2b6b170)
#17 0x00000000030f9244 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x30f9244)
#18 0x00000000026e1e20 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-7+0x26e1e20)
#19 0x000000000268b231
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x268b231)
#20 0x00000000027863d9
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x27863d9)
#21 0x00000000009147d8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-7+0x9147d8)
#22 0x000000000091211f main
(/home/absozero/trunk/root-clang/bin/clang-7+0x91211f)
#23 0x00007fb624329f45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#24 0x000000000090f1ad _start
(/home/absozero/trunk/root-clang/bin/clang-7+0x90f1ad)
clang-7: error: unable to execute command: Aborted (core dumped)
clang-7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 334695)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-7: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7: note: diagnostic msg: /tmp/abc-6b9e78.c
clang-7: note: diagnostic msg: /tmp/abc-6b9e78.sh
clang-7: note: diagnostic msg:

********************


$ cat abc.c
char a;
short b;
long c, d;
unsigned e;
void fn1() {
l1:;
  long f;
  for (; d;) {
    short *g;
    f = 8;
    c && (a = e);
    (0xB43AD2C2 % 0 | 5) / (f *= e) ?: (e = f);
    goto l1;
  l2:
    b ? *g : 0;
    g = &f;
  }
  goto l2;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180615/398d6362/attachment-0001.html>


More information about the llvm-bugs mailing list