[LLVMdev] A question of Sparc assembly generated by llc

Venkatraman Govindaraju venkatra at cs.wisc.edu
Thu Jan 12 13:23:20 PST 2012


Hi Chris,

  'subcc' instruction is necessary for 'bne' to work correctly.
Conditional flags (ICC, FCC) are clobbered by Call instructions in
Sparc. They are not saved and restored around call instructions.
  What is the version of LLVM that you used? If this code is generated
by recent LLVM, please file a bug report with a testcase.

Thanks,
Venkatraman

On Thu, Jan 12, 2012 at 12:48 PM, ckathy <clcheng at stanford.edu> wrote:
>
> Hi,
>
>
> There are some generated Sparc assembly code like this:
>
> main:                                   ! @main
> ! BB#0:
>        save %sp, -112, %sp
>        sethi 0, %l0
>        or %g0, 5, %l1
>        st %l0, [%fp+-4]
>        st %l1, [%fp+-8]
>        st %l1, [%fp+-12]
>        sethi %hi(.L.str), %l1
>        ld [%fp+-8], %o1
>        add %l1, %lo(.L.str), %l1
>        or %g0, %l1, %o0
>        call printf
>        nop
>        ld [%fp+-12], %o2
>        ld [%fp+-8], %l2
>        sethi %hi(.L.strQ521), %l3
>        add %l3, %lo(.L.strQ521), %o0
>        or %g0, %l2, %o1
>        call MY_FUNCTION
>        nop
>        or %g0, 1, %i0
>       (subcc %l1, 0, %l1  ! This line is added by me. It was not there)
>        bne .LBB0_2
>        nop
> ! BB#1:
>        subcc %l2, 0, %l2
>        or %g0, %l0, %i0
> .LBB0_2:
>       .......
>
>
> I am not an expert on Sparc assembly, but I read from somewhere that
> branching instructions are set by the statues flags. The first 'bne'
> statement appeared before any subcc or any other cc opcodes. The code is
> problematic so I added the line in the brackets based on what I think it
> should be doing and it appeared to be working correctly.
>
> Is the standalone 'bne' instruction intentional?  There are some integer
> condition code in MY_FUNCTION but I thought the iCC flags will be saved
> before the 'call' statement and restored after the 'call' statement. Is it
> correct?
>
> By the way, there are 'save %sp, -96, %sp', 'restore %g0, %g0, %g0' and
> 'retl' statements in MY_FUNCTION.
>
> Thanks,
>
> Chris
>
>
> --
> View this message in context: http://old.nabble.com/A-question-of-Sparc-assembly-generated-by-llc-tp33129811p33129811.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list