ssrg-vt / popcorn-compiler

Popcorn Linux compiler toolchain for heterogeneous-ISA execution
41 stars 22 forks source link

Failed assertion in CodeGen/UnwindInfo.cpp #19

Closed acarno closed 6 years ago

acarno commented 6 years ago

When building libopenpop with -popcorn-migratable, compilation of task.c crashes the compiler due to a failed assertion in /llvm/lib/CodeGen/UnwindInfo.cpp:

depbase=`echo task.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/bash ./libtool  --tag=CC   --mode=compile /usr/local/popcorn/x86_64/bin/musl-clang -DHAVE_CONFIG_H -I.  -I./config/linux -I./config/posix -I.  -Wall -Werror -ftls-model=initial-exec -Wc,-pthread -target x86_64-linux-gnu -nostdinc -isystem /usr/local/popcorn/x86_64/include -popcorn-migratable -Wno-error -pthread -popcorn-alignment -fno-common  -MT task.lo -MD -MP -MF $depbase.Tpo -c -o task.lo task.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  /usr/local/popcorn/x86_64/bin/musl-clang -DHAVE_CONFIG_H -I. -I./config/linux -I./config/posix -I. -Wall -Werror -pthread -ftls-model=initial-exec -target x86_64-linux-gnu -nostdinc -isystem/usr/local/popcorn/x86_64/include -popcorn-migratable -Wno-error -pthread -popcorn-alignment -fno-common-MT task.lo -MD -MP -MF .deps/task.Tpo -c task.c -o task.o
clang-3.7: /usr/local/popcorn/src/llvm/lib/CodeGen/UnwindInfo.cpp:49: void llvm::UnwindInfo::recordUnwindInfo(const llvm::MachineFunction&): Assertion `FrameReg == TRI->getFrameRegister(MF) && "Invalid register used as offset for unwinding information"' failed.
0  libLLVMSupport.so.3.7        0x00007fba10ae1950 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 44
1  libLLVMSupport.so.3.7        0x00007fba10ae1cc7
2  libLLVMSupport.so.3.7        0x00007fba10ae08c2
3  libc.so.6                    0x00007fba0daf8030
4  libc.so.6                    0x00007fba0daf7fcf gsignal + 207
5  libc.so.6                    0x00007fba0daf93fa abort + 362
6  libc.so.6                    0x00007fba0daf0e37
7  libc.so.6                    0x00007fba0daf0ee2
8  libLLVMCodeGen.so.3.7        0x00007fba13b4d038 llvm::UnwindInfo::recordUnwindInfo(llvm::MachineFunction const&) + 562
9  libLLVMAArch64CodeGen.so.3.7 0x00007fba16a4e486
10 libLLVMCodeGen.so.3.7        0x00007fba1398fb43 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
11 libLLVMCore.so.3.7           0x00007fba13052f2d llvm::FPPassManager::runOnFunction(llvm::Function&) +315
12 libLLVMCore.so.3.7           0x00007fba1305308c llvm::FPPassManager::runOnModule(llvm::Module&) + 118
13 libLLVMCore.so.3.7           0x00007fba130533bb
14 libLLVMCore.so.3.7           0x00007fba13053a1e llvm::legacy::PassManagerImpl::run(llvm::Module&) + 264
15 libLLVMCore.so.3.7           0x00007fba13053c0f llvm::legacy::PassManager::run(llvm::Module&) + 39
16 libclangCodeGen.so.3.7       0x00007fba0f3a3a0d
17 libclangCodeGen.so.3.7       0x00007fba0f3a3eff clang::CodegenBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_pwrite_stream*) + 492
18 libclangCodeGen.so.3.7       0x00007fba0f5c1efe
19 libclangParse.so.3.7         0x00007fba09afacec clang::ParseAST(clang::Sema&, bool, bool) + 789
20 libclangFrontend.so.3.7      0x00007fba0eb643bb clang::ASTFrontendAction::ExecuteAction() + 323
21 libclangCodeGen.so.3.7       0x00007fba0f5bf8ed clang::EmitMultiObjAction::ExecuteAction() + 1065
22 libclangFrontend.so.3.7      0x00007fba0eb63e75 clang::FrontendAction::Execute() + 139
23 libclangFrontend.so.3.7      0x00007fba0eb19609 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 785
24 libclangFrontendTool.so.3.7  0x00007fba0e70a27e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1120
25 clang-3.7                    0x000055e32db3c937 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 980
26 clang-3.7                    0x000055e32db33d6a
27 clang-3.7                    0x000055e32db34253 main + 1041
28 libc.so.6                    0x00007fba0dae52b1 __libc_start_main + 241
29 clang-3.7                    0x000055e32db325ca _start + 42
Stack dump:
0.      Program arguments: /usr/local/popcorn/bin/clang-3.7 -cc1 -triple x86_64--linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name task.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -coverage-file /home/anthony/Research/popcorn-compiler/lib/libopenpop/task.o -nostdsysteminc -nobuiltininc -resource-dir /usr/local/popcorn/bin/../lib/clang/3.7.1 -dependency-file .deps/task.Tpo -sys-header-deps -MP -MT task.lo -isystem /usr/local/popcorn/x86_64/include -isystem /usr/local/popcorn/x86_64/include -D HAVE_CONFIG_H -I . -I ./config/linux -I ./config/posix -I . -isysroot /usr/local/popcorn/x86_64 -Wall -Werror -Wno-error -fdebug-compilation-dir /home/anthony/Research/popcorn-compiler/lib/libopenpop -ferror-limit 19 -fmessage-length 105 -ftls-model=initial-exec -pthread -mstackrealign -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -ffunction-sections -fdata-sections -popcorn-alignment -popcorn-migratable -mllvm -popcorn-instrument=migration -mllvm -optimize-regalloc -mllvm -fast-isel=false -o task.o -x c task.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'task.c'.
4.      Running pass 'AArch64 Assembly Printer' on function '@GOMP_task'
clang-3.7: error: unable to execute command: Aborted
clang-3.7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.1 (tags/RELEASE_371/final 325143) (llvm/tags/RELEASE_371/final 325142)
Target: x86_64--linux-gnu
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.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-3.7: note: diagnostic msg: /tmp/task-da5cca.c
clang-3.7: note: diagnostic msg: /tmp/task-da5cca.sh
clang-3.7: note: diagnostic msg:

********************
Makefile:716: recipe for target 'task.lo' failed
make[1]: *** [task.lo] Error 1
make[1]: Leaving directory '/home/anthony/Research/popcorn-compiler/lib/libopenpop'
Makefile:530: recipe for target 'all' failed
make: *** [all] Error 2

Steps to reproduce:

  1. Patch musl-1.1.18 with attached patch (note: this just modifies the musl-clang script, so you can manually modify it if you don't want to re-install the library).
  2. Configure libopenpop with following command:
    CC="/usr/local/popcorn/x86_64/bin/musl-clang" CFLAGS="-target x86_64-linux-gnu -nostdinc -isystem /usr/local/popcorn/x86_64/include -popcorn-migratable -Wno-error" ./configure --prefix=/usr/local/popcorn/x86_64/ --target=x86_64-linux-gnu --host=x86_64-linux-gnu --enable-static --disable-shared
  3. Build with make

Attached files include:

acarno commented 6 years ago

Adding preprocessed source & associated run script (generated by Clang)

additional_sources.tar.gz

rlyerly commented 6 years ago

This is actually a compatibility problem -- the file contains several functions with dynamically-sized stack frames, which are not supported by the toolchain yet. The following functions & variables should be rewritten to use gomp_malloc/free instead of dynamically-sized stack allocations:

GOMP_task: variable "char buf[]" is dynamically-sized GOMP_taskloop: variables "struct gomp_task task[]", "char buf[]", "struct gomp_task *tasks[]" are dynamically sized