Skip to content

compiler crash when using pgo #30

@wheatman

Description

@wheatman

tapir seems to crash whenever I try and compile something that uses profiles and has a cilk_for loop in it.
I used the following small example

#include <cilk/cilk.h>

int main() {
  int sum = 0;
  cilk_for(int i = 0; i < 1000000; i++) { sum += i; }

  return sum;
}

I compiled it as follows

../OpenCilk-9.0.1-Linux/bin/clang++  -g  -fopencilk  -lopencilk -fprofile-instr-generate -o profile del.cpp
./profile
../OpenCilk-9.0.1-Linux//bin/llvm-profdata merge -output=code.profdata default.profraw
../OpenCilk-9.0.1-Linux/bin/clang++  -g  -fopencilk  -lopencilk -fprofile-instr-use=code.profdata -o opt del.cpp

The version I am running is

../OpenCilk-9.0.1-Linux/bin/clang++ --version
clang version 9.0.1 ([email protected]:CilkHub/opencilk-project.git 48265098754b785d1b06cb08d8e22477a003efcd)
Target: x86_64-unknown-linux-gnu
Thread model: posix

The full backtrace is

clang-9: /home/gridsan/tschardl/opencilk-project/clang/lib/CodeGen/CodeGenPGO.cpp:1053: llvm::MDNode* clang::CodeGen::CodeGenFunction::createProfileWeightsForLoop(const clang::Stmt*, uint64_t): Assertion `CondCount.hasValue() && "missing expected loop condition count"' failed.
Stack dump:
0. Program arguments: /home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name del.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -fprofile-instrument-use-path=code.profdata -resource-dir /home/wheatman/OpenCilk-9.0.1-Linux/lib/clang/9.0.1 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /home/wheatman/OpenCilk-9.0.1-Linux/lib/clang/9.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/wheatman/PMA -ferror-limit 19 -fmessage-length 0 -fopencilk -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o /tmp/del-e9abb3.o -x c++ del.cpp

  1.  <eof> parser at end of file
    
  2.  del.cpp:3:5: LLVM IR generation of declaration 'main'
    
  3.  del.cpp:3:5: Generating code for declaration 'main'
    

#0 0x0000564f81acb62a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1aa462a)
#1 0x0000564f81ac92d4 llvm::sys::RunSignalHandlers() (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1aa22d4)
#2 0x0000564f81ac9412 SignalHandler(int) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1aa2412)
#3 0x00007fa40070e980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x00007fa3ff568fb7 raise /build/glibc-S7xCS9/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007fa3ff56a921 abort /build/glibc-S7xCS9/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007fa3ff55a48a __assert_fail_base /build/glibc-S7xCS9/glibc-2.27/assert/assert.c:89:0
#7 0x00007fa3ff55a502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
#8 0x0000564f81de032f clang::CodeGen::CodeGenFunction::createProfileWeightsForLoop(clang::Stmt const*, unsigned long) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1db932f)
#9 0x0000564f81ed0450 clang::CodeGen::CodeGenFunction::EmitCilkForStmt(clang::CilkForStmt const&, llvm::ArrayRef<clang::Attr const*>) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1ea9450)
#10 0x0000564f81d55db7 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1d2edb7)
#11 0x0000564f81d5635c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1d2f35c)
#12 0x0000564f81d91437 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1d6a437)
#13 0x0000564f81da102d clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1d7a02d)
#14 0x0000564f81dd91bf clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1db21bf)
#15 0x0000564f81dd6a85 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1dafa85)
#16 0x0000564f81dd716b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1db016b)
#17 0x0000564f81ddd2a9 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5677) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x1db62a9)
#18 0x0000564f82760e4d (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x2739e4d)
#19 0x0000564f827553c1 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x272e3c1)
#20 0x0000564f831c5304 clang::ParseAST(clang::Sema&, bool, bool) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x319e304)
#21 0x0000564f8275cd48 clang::CodeGenAction::ExecuteAction() (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x2735d48)
#22 0x0000564f821d8869 clang::FrontendAction::Execute() (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x21b1869)
#23 0x0000564f8219c441 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x2175441)
#24 0x0000564f82283eff clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0x225ceff)
#25 0x0000564f80ba2fbf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0xb7bfbf)
#26 0x0000564f80b447e9 main (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0xb1d7e9)
#27 0x00007fa3ff54bbf7 __libc_start_main /build/glibc-S7xCS9/glibc-2.27/csu/../csu/libc-start.c:344:0
#28 0x0000564f80b9e7aa _start (/home/wheatman/OpenCilk-9.0.1-Linux/bin/clang-9+0xb777aa)
clang-9: error: unable to execute command: Aborted
clang-9: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.1 ([email protected]:CilkHub/opencilk-project.git 4826509)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wheatman/PMA/../OpenCilk-9.0.1-Linux/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to https://github.com/OpenCilk/opencilk-project/issues and include the crash backtrace, preprocessed source, and associated run script.
clang-9: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/del-4803b7.cpp
clang-9: note: diagnostic msg: /tmp/del-4803b7.sh
clang-9: note: diagnostic msg:


del-4803b7.sh.txt
del-4803b7.cpp.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions