[LLVMbugs] [Bug 17354] New: powerpc64 -fPIC missing required nop

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 24 18:24:55 PDT 2013


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

            Bug ID: 17354
           Summary: powerpc64 -fPIC missing required nop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: hfinkel at anl.gov, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Repro with "clang -target powerpc64-pc-linux-gnu test.ii -fPIC -S -o -",
testcase:

  struct CS {
    int a_;
  };

  CS func();

  static CS glb[1] = {
    func()
  };

  CS func() {
    CS cs;
    cs.a_ = 0;
    return cs;
  }

Clang generates the same assembly with and without -fPIC. GCC adds a 'nop'
after the call to func. Clang's asm does this:

[...]
        .cfi_def_cfa_register r31
        addis 3, 2, _ZL3glb at toc@ha
        addi 3, 3, _ZL3glb at toc@l
        bl _Z4funcv
        addi 1, 1, 128
        ld 0, 16(1)
        ld 31, -8(1)
        mtlr 0
        blr
[...]

while GCC -fPIC emits:

[...]
        cmpw 7,10,9
        bne 7,.L3
        addis 9,2,_ZL3glb at toc@ha
        addi 9,9,_ZL3glb at toc@l
        mr 3,9
        bl _Z4funcv
        nop
.L3:
        addi 1,31,128
        .cfi_def_cfa 1, 0
        ld 0,16(1)
[...]

The linker (binutils gold 2.23.52.20130305) complains "other.cc:4: error: call
lacks nop, can't restore toc; recompile with -fPIC" when trying to link a final
program, after having built the code in the testcase into a .so.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130925/c7a15e49/attachment.html>


More information about the llvm-bugs mailing list