[LLVMbugs] [Bug 6144] New: GP is used before restored after a library call

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Jan 26 00:25:09 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=6144

           Summary: GP is used before restored after a library call
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: ASSIGNED
          Keywords: ABI
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: bruno.cardoso at gmail.com
        ReportedBy: joe_shuchang_zhou at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


; ModuleID = 'gp.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"

@.str = private constant [3 x i8] c"hi\00", align 1 ; <[3 x i8]*> [#uses=1]
@i = common global i32 0                          ; <i32*> [#uses=1]

define i32 @main() nounwind {
entry:
  %0 = tail call i32 @puts(i8* getelementptr inbounds ([3 x i8]* @.str, i32 0,
i32 0)) nounwind ; <i32> [#uses=0]
  store i32 3, i32* @i, align 4
  ret i32 0
}

declare i32 @puts(i8* nocapture) nounwind

-------------------
Code above segfaults after following commands.
llc -O0 -mcpu=r6000 -march=mips -mattr=+o32 gp.ll -o gp.s
mipsel-unknown-linux-gnu-gcc -mips3 gp.s -o gp
./gp

By GDB, it is because in assembly we have
        lw      $25, %call16(puts)($gp)
        nop
        jalr    $25
        nop
        lw      $2, %got(i)($gp)
                           ~~~~~$gp is used before restored
        nop
        lw      $3, 16($sp)
        nop
        addiu   $4, $zero, 3
        addu    $gp, $zero, $3
        sw      $4, 0($2)


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list