[LLVMbugs] [Bug 7544] New: Wrong offset for struct member

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 1 10:13:42 PDT 2010


           Summary: Wrong offset for struct member
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ofv at wanadoo.es
                CC: llvmbugs at cs.uiuc.edu

Consider this llvm assembly code that assigns values to the data members of a

; ModuleID = 'lp0'
target datalayout =
target triple = "i686-pc-win32"

%0 = type { i32, double }

declare void @abort()

define void @mainf() {
  %sdafo_ = alloca %0                             ; <%0*> [#uses=2]
  %pts1_4 = getelementptr %0* %sdafo_, i32 0, i32 0 ; <int*> [#uses=1]
  store i32 15, i32* %pts1_4
  %pts1_1 = getelementptr %0* %sdafo_, i32 0, i32 1 ; <double*> [#uses=1]
  store double 2.100000e+001, double* %pts1_1
  ret void

All data is aligned to 32 bits (with the platform's default settings for the
datalayout, the result is the same) but the generated assembly code is:

    .def     _mainf;
    .scl    2;
    .type    32;
    .globl    _mainf
    .align    16, 0x90
_mainf:                                 # @mainf
# BB#0:
    subl    $20, %esp
    movl    $15, (%esp)
    movl    $1077215232, 12(%esp)   # imm = 0x40350000
    movl    $0, 8(%esp)
    addl    $20, %esp

The second data member (with type `double') is 12 bytes away from the first
data member of type `int', leaving 8 bytes of padding between them.

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