[llvm-dev] DragonEgg for GCC v8.x and LLVM v6.x is just able to work

Leslie Zhai via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 21 20:48:21 PDT 2017


Hi Tobias,

Thanks for your kind response!


在 2017年08月21日 18:42, Tobias Grosser 写道:
> On Mon, Aug 21, 2017, at 05:31, Leslie Zhai via llvm-dev wrote:
>> Hi LLVM and GCC developers,
>>
>> My sincere thanks will goto:
>>
>> * Duncan, the core developer of llvm-gcc and dragonegg
>> http://llvm.org/devmtg/2009-10/Sands_LLVMGCCPlugin.pdf
>>
>> * David, the innovator and developer of GCC
>> https://dmalcolm.fedorapeople.org/gcc/global-state/requirements.html
>>
>> and others who give me kind response for teaching me patiently and
>> carefully about how to migrate GCC v4.8.x to GCC v8.x (git-20170818)
>>
>> DragonEgg has been migrated to GCC v8.x and LLVM v6.x (svn-r311142), but
>> also able to work for GCC v4.8.x and LLVM v3.3
>> https://reviews.llvm.org/D35667 and it is just able to work now, for
>> example:
> Very interesting. We are still using dragonegg to process our weather
> modeling codes here at ETH / CSCS. Having it updated to work with latest
> LLVM will provide us with a current baseline which will also be helpful
> to evaluate flang further. Thanks a lot for your effort.
GIMPLE -> LLVM IR is just able to work, but Target (x86 
https://github.com/xiangzhai/dragonegg/tree/master/src/x86   or arm, 
mips) hasn't been migrated yet, so at present it works as:

GCC Frontend -> GIMPLE -> LLVM IR

so it needs llc for LLVM IR -> Assembly (Target depended)

and I am maintaining AVR Target recently, for example: Migrate to new 
MCAsmBackend applyFixup and processFixupValue 
https://reviews.llvm.org/D34551  I am considering how to reuse LLVM's 
lib/Target for supporting more chipset and write less (Target for 
DragonEgg) by myself :)


>
> Best,
> Tobias
>
> PS: Would be great to have a flang update on the mailing list as well. I
> will ask for this in a separate email.
I also migrated flang-clang to LLVM 6.0.0svn-r311323 and waiting for 
rebase the patch 
https://github.com/flang-compiler/clang/pull/28#issuecomment-323147978


>
>>
>> $CC -fplugin=./dragonegg.so \
>>           -fplugin-arg-dragonegg-debug-pass-arguments \
>>           -ftime-report \
>>           -fverbose-asm \
>>           -fplugin-arg-dragonegg-enable-gcc-optzns \
>>           -fplugin-arg-dragonegg-emit-ir \
>>           -S \
>>           test/hello.c \
>>           -wrapper gdb,--args
>>
>>
>> hello.s (LLVM IR, the extension name is not important)
>>
>> ; ModuleID = 'test/hello.c'
>> source_filename = "test/hello.c"
>> target triple = "x86_64-redhat-linux"
>>
>> module asm "\09.ident\09\22GCC: (GNU) 6.4.1 20170727 (Red Hat 6.4.1-1)
>> LLVM: 3.9.1\22"
>>
>> @__func__.2210 = internal local_unnamed_addr constant [4 x i8] c"foo\00"
>> @.cst = private local_unnamed_addr constant [24 x i8] c"DEBUG: %s, line
>> %d: %s\0A\00", align 8
>> @.cst.1 = private local_unnamed_addr constant [13 x i8]
>> c"test/hello.c\00", align 8
>> @.cst.2 = private local_unnamed_addr constant [12 x i8] c"Leslie
>> Zhai\00", align 8
>> @.cst.3 = private local_unnamed_addr constant [20 x i8] c"%s: Hello
>> World %d\0A\00", align 8
>>
>> ; Function Attrs: nounwind uwtable
>> define void @foo(...) unnamed_addr #0 {
>> entry:
>>     %"ssa point" = bitcast i32 0 to i32
>>     br label %"<bb 2>"
>>
>> "<bb 2>":                                         ; preds = %entry
>>     %0 = call i32 (i8*, ...) @printf(i8* noalias getelementptr inbounds
>> ([24 x i8], [24 x i8]* @.cst, i64 0, i64 0), [13 x i8]* @.cst.1, i32 4,
>> [4 x i8]* @__func__.2210) #1
>>     br label %return
>>
>> return:                                           ; preds = %"<bb 2>"
>>     ret void
>> }
>>
>> declare i32 @printf(i8*, ...)
>>
>> ; Function Attrs: nounwind uwtable
>> define i32 @main(i32 %argc, i8** %argv) unnamed_addr #0 {
>> entry:
>>     %argc_addr = alloca i32, align 4
>>     %argv_addr = alloca i8**, align 8
>>     %n = alloca i32
>>     %s = alloca i8*
>>     %"<retval>" = alloca i32
>>     %"alloca point" = bitcast i32 0 to i32
>>     store i32 %argc, i32* %argc_addr, align 1
>>     store i8** %argv, i8*** %argv_addr, align 1
>>     %"ssa point" = bitcast i32 0 to i32
>>     br label %"<bb 2>"
>>
>> "<bb 2>":                                         ; preds = %entry
>>     %0 = call i32 (i8*, ...) @printf(i8* noalias getelementptr inbounds
>> ([20 x i8], [20 x i8]* @.cst.3, i64 0, i64 0), i8* getelementptr
>> inbounds ([12 x i8], [12 x i8]* @.cst.2, i64 0, i64 0), i32 1) #1
>>     br label %"<L0>"
>>
>> "<L0>":                                           ; preds = %"<bb 2>"
>>     store i32 0, i32* %"<retval>", align 1
>>     br label %return
>>
>> return:                                           ; preds = %"<L0>"
>>     %1 = load i32, i32* %"<retval>", align 4
>>     ret i32 %1
>> }
>>
>> attributes #0 = { nounwind uwtable
>> "no-frame-pointer-elim-non-leaf"="true" }
>> attributes #1 = { nounwind }
>>
>> !llvm.module.flags = !{!0}
>>
>> !0 = !{i32 1, !"PIE Level", i32 2}
>>
>>
>> $ llc hello.s
>>
>>       .text
>>       .file    "hello.s"
>>                                           # Start of file scope inline
>> assembly
>>       .ident    "GCC: (GNU) 6.4.1 20170727 (Red Hat 6.4.1-1) LLVM: 3.9.1"
>>
>>                                           # End of file scope inline
>>                                           assembly
>>       .globl    foo
>>       .p2align    4, 0x90
>>       .type    foo, at function
>> foo:                                    # @foo
>>       .cfi_startproc
>> # BB#0:                                 # %entry
>>       pushq    %rbp
>> .Ltmp0:
>>       .cfi_def_cfa_offset 16
>> .Ltmp1:
>>       .cfi_offset %rbp, -16
>>       movq    %rsp, %rbp
>> .Ltmp2:
>>       .cfi_def_cfa_register %rbp
>>       movl    $.L.cst, %edi
>>       movl    $.L.cst.1, %esi
>>       movl    $4, %edx
>>       movl    $__func__.2210, %ecx
>>       xorl    %eax, %eax
>>       callq    printf
>>       popq    %rbp
>>       retq
>> .Lfunc_end0:
>>       .size    foo, .Lfunc_end0-foo
>>       .cfi_endproc
>>
>>       .globl    main
>>       .p2align    4, 0x90
>>       .type    main, at function
>> main:                                   # @main
>>       .cfi_startproc
>> # BB#0:                                 # %entry
>>       pushq    %rbp
>> .Ltmp3:
>>       .cfi_def_cfa_offset 16
>> .Ltmp4:
>>       .cfi_offset %rbp, -16
>>       movq    %rsp, %rbp
>> .Ltmp5:
>>       .cfi_def_cfa_register %rbp
>>       subq    $32, %rsp
>>       movl    %edi, -8(%rbp)
>>       movq    %rsi, -16(%rbp)
>>       movl    $.L.cst.3, %edi
>>       movl    $.L.cst.2, %esi
>>       movl    $1, %edx
>>       xorl    %eax, %eax
>>       callq    printf
>>       movl    $0, -4(%rbp)
>>       movl    -4(%rbp), %eax
>>       addq    $32, %rsp
>>       popq    %rbp
>>       retq
>> .Lfunc_end1:
>>       .size    main, .Lfunc_end1-main
>>       .cfi_endproc
>>
>>       .type    __func__.2210, at object   # @__func__.2210
>>       .section    .rodata,"a", at progbits
>> __func__.2210:
>>       .asciz    "foo"
>>       .size    __func__.2210, 4
>>
>>       .type    .L.cst, at object          # @.cst
>>       .p2align    3
>> .L.cst:
>>       .asciz    "DEBUG: %s, line %d: %s\n"
>>       .size    .L.cst, 24
>>
>>       .type    .L.cst.1, at object        # @.cst.1
>>       .p2align    3
>> .L.cst.1:
>>       .asciz    "test/hello.c"
>>       .size    .L.cst.1, 13
>>
>>       .type    .L.cst.2, at object        # @.cst.2
>>       .p2align    3
>> .L.cst.2:
>>       .asciz    "Leslie Zhai"
>>       .size    .L.cst.2, 12
>>
>>       .type    .L.cst.3, at object        # @.cst.3
>>       .p2align    3
>> .L.cst.3:
>>       .asciz    "%s: Hello World %d\n"
>>       .size    .L.cst.3, 20
>>
>>
>>       .section    ".note.GNU-stack","", at progbits
>>
>>
>> $ clang hello.s.s
>>
>> $ ./a.out
>>
>> Leslie Zhai: Hello World 1
>>
>>
>> WIP:
>>
>> * fix issues https://github.com/xiangzhai/dragonegg/issues
>>
>> * gengtype not support macro
>> https://gcc.gnu.org/ml/gcc/2017-07/msg00045.html
>>
>> -- 
>> Regards,
>> Leslie Zhai - a LLVM developer https://reviews.llvm.org/p/xiangzhai/
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-- 
Regards,
Leslie Zhai - a LLVM developer https://reviews.llvm.org/p/xiangzhai/





More information about the llvm-dev mailing list