[LLVMbugs] [Bug 8327] New: LLVM miscompiles va_arg() on 64-bit PowerPC, truncating address to 32 bits

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 7 07:24:45 PDT 2010


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

           Summary: LLVM miscompiles va_arg() on 64-bit PowerPC,
                    truncating address to 32 bits
           Product: new-bugs
           Version: trunk
          Platform: Macintosh
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nwhitehorn at freebsd.org
                CC: llvmbugs at cs.uiuc.edu


On 64-bit PowerPC, LLVM trunk (r115623) miscompiles va_arg:
        %3 = va_arg i8** %foo, i8*                      ; <i8*> [#uses=2]

to this code:
        lis 3, 8191
        ori 3, 3, 65535      # r3 now contains 0x1ffffff
        ld 4, 296(31)        # address of foo in r4
        addi 4, 4, 7         # some kind of rounding with the next masking?
        sldi 3, 3, 3         # r3 is now mask 0xfffffff8  
        and 3, 4, 3          # and with r4, truncating foo to 8-byte alignment
                             # (and killing top 32 bits)
        addi 4, 3, 8         # increment foo (r4) to next VA arg
        std 4, 296(31)       # store back to foo

Because the generated mask is only 32 bits wide, anding it with the VA arg
pointer has the effect of zeroing the high 32-bits, causing a seg fault. I'm
not entirely sure why it goes to the trouble of all the rounding code here, but
the mask should at least be 64 bits on this platform.

-- 
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