xiangzhai / dragonegg

DragonEgg has been migrated to GCC 8 and LLVM 6 but also able to work for GCC 4.8 and LLVM 3.3
https://gcc.gnu.org/ml/gcc/2017-08/msg00245.html
GNU General Public License v2.0
18 stars 6 forks source link

Pure virtual method called (GCC-4.8) #37

Open my-HenryS opened 5 years ago

my-HenryS commented 5 years ago

Hi,

Thank you for providing support to new versions of LLVM.

I am trying to use dragonegg with LLVM 6.0.0 and GCC-4.8. I applied some workarounds (mostly related to the path of headers or obsolete APIs, https://github.com/my-HenryS/dragonegg/tree/dev) to get over those compilation errors.

I got the following error message when I am trying to apply it to a fortran program:

mpif90 -O0 -g -S -fplugin=/path/to/softwares/dragonegg/dragonegg.so -fplugin-arg-dragonegg-emit-ir ssor.f -o /path/to/npb/LU/MPITCC_WORKSPACE/ssor.f.ll

WARNING there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins. Event | Plugins PLUGIN_FINISH_UNIT | dragonegg PLUGIN_FINISH | dragonegg PLUGIN_START_UNIT | dragonegg PLUGIN_ALL_IPA_PASSES_END | dragonegg exchange_3.f: In function 'exchange3': exchange_3.f:5:0: internal compiler error: Segmentation fault subroutine exchange_3(g,iex) ^ Please submit a full bug report, with preprocessed source if appropriate. See file:///usr/share/doc/gcc-4.8/README.Bugs for instructions. pure virtual method called terminate called without an active exception

I also tried different versions of LLVM including v4.x and v5.x but all result in similar problems. Previously I am using LLVM 3.5 (and gcc-4.8) with dragonegg but for some reason I decide to migrate my project to higher versions, so I am trying to have dragonegg working.

xiangzhai commented 5 years ago

Hi @my-HenryS

Please try:

mpif90 -fplugin=/path/to/softwares/dragonegg/dragonegg.so \
        -fplugin-arg-dragonegg-debug-pass-arguments \
        -ftime-report \
        -fverbose-asm \
        -fplugin-arg-dragonegg-enable-gcc-optzns \
        -fplugin-arg-dragonegg-emit-ir \
         -O0 -g \
        -S \
        ssor.f \
        -o /path/to/npb/LU/MPITCC_WORKSPACE/ssor.f.ll \
        -wrapper gdb,--args

And see what gdb say?

Leslie Zhai

my-HenryS commented 5 years ago

Hi @xiangzhai,

Here is the follow-up. I have to remove the '-fverbose-asm' flag for it is disabled on the cluster I'm using.

The program terminates with the following output.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff2b8501e in llvm::TrackingMDRef::get (this=0x30)
    at /path/to/softwares/llvm-6.0.0.src/include/llvm/IR/TrackingMDRef.h:58
58    Metadata *get() const { return MD; }

Thanks you for your time.

xiangzhai commented 5 years ago

Could you bt to provide more detailed trace information?

my-HenryS commented 5 years ago

@xiangzhai I got the following output.

(gdb) bt
#0  0x00007ffff2b8501e in llvm::TrackingMDRef::get (this=0x30)
    at /home/sunjh/softwares/llvm-6.0.0.src/include/llvm/IR/TrackingMDRef.h:58
#1  0x00007ffff2b928fc in llvm::TypedTrackingMDRef<llvm::MDNode>::get (this=0x30)
    at /home/sunjh/softwares/llvm-6.0.0.src/include/llvm/IR/TrackingMDRef.h:127
#2  0x00007ffff2caea32 in llvm::DebugLoc::get (this=0x30)
    at /home/sunjh/softwares/llvm-6.0.0.src/lib/IR/DebugLoc.cpp:22
#3  0x00007ffff6a7439e in llvm::DebugLoc::operator llvm::DILocation* (this=0x30)
    at /home/sunjh/softwares/llvm-6.0.0.src/include/llvm/IR/DebugLoc.h:56
#4  0x00007ffff6a70010 in DebugInfo::EmitDeclare (this=0x15135f0, decl=0x7ffff6df0200,
    Tag=4294967295, Name=..., type=0x7ffff6e04150, AI=0x14e2dd8, IRBuilder=...)
    at /home/sunjh/softwares/dragonegg-3.9.0.src/src/Debug.cpp:485
#5  0x00007ffff6a2df45 in TreeToLLVM::StartFunctionBody (this=0x7fffffffbf90)
    at /home/sunjh/softwares/dragonegg-3.9.0.src/src/Convert.cpp:1293
#6  0x00007ffff6a30585 in TreeToLLVM::EmitFunction (this=0x7fffffffbf90)
    at /home/sunjh/softwares/dragonegg-3.9.0.src/src/Convert.cpp:1876
#7  0x00007ffff6a0b5a8 in emit_current_function ()
    at /home/sunjh/softwares/dragonegg-3.9.0.src/src/Backend.cpp:2058
#8  0x00007ffff6a0b645 in rtl_emit_function ()
    at /home/sunjh/softwares/dragonegg-3.9.0.src/src/Backend.cpp:2093
#9  0x00000000007fa049 in execute_one_pass(opt_pass*) ()
#10 0x00000000007fa425 in execute_pass_list(opt_pass*) ()
#11 0x00000000006562de in ?? ()
#12 0x0000000000657adb in compile() ()
#13 0x0000000000657cda in finalize_compilation_unit() ()
#14 0x00000000007a0245 in write_global_declarations() ()
#15 0x000000000088939d in ?? ()
#16 0x000000000088ae8a in toplev_main(int, char**) ()
#17 0x00007ffff6f12830 in __libc_start_main (main=0x501830 <main>, argc=26,
    argv=0x7fffffffcb48, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffcb38) at ../csu/libc-start.c:291
#18 0x00000000005018a9 in _start ()
my-HenryS commented 5 years ago

I think it might have sth to do with the following code fragment:

#if LLVM_VERSION_CODE > LLVM_VERSION(5, 0)
    TinyPtrVector<DbgInfoIntrinsic *> DbgDeclares = FindDbgAddrUses(AI);
     DbgInfoIntrinsic* DbgDecl = DbgDeclares.front();
#else

Originally it gives the following error message: f951: /home/sunjh/softwares/llvm-6.0.0.src/include/llvm/ADT/TinyPtrVector.h:222: EltTy llvm::TinyPtrVector::front() const [with EltTy = llvm::DbgInfoIntrinsic*]: Assertion `!empty() && "vector empty"' failed. As you might have seen from my modifications, I tried to bypass this error.

xiangzhai commented 5 years ago

Oops, my bad, I haven't migrated DebuInfo to LLVM 6 https://github.com/xiangzhai/dragonegg/issues/32 Please try to migrate that!

So workaround:

mpif90 -fplugin=/path/to/softwares/dragonegg/dragonegg.so \
        -fplugin-arg-dragonegg-debug-pass-arguments \
        -ftime-report \
        -fplugin-arg-dragonegg-enable-gcc-optzns \
        -fplugin-arg-dragonegg-emit-ir \
        -O0  \
        -S \
        ssor.f \
        -o /path/to/npb/LU/MPITCC_WORKSPACE/ssor.f.ll \
        -wrapper gdb,--args
xiangzhai commented 5 years ago

You can try flang https://github.com/flang-compiler/flang

my-HenryS commented 5 years ago

@xiangzhai Thank you for your advice. I will look into it.

Jinghan