[LLVMbugs] [Bug 15743] New: gep problem when optimizer changes struct padding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 13 14:52:01 PDT 2013


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

            Bug ID: 15743
           Summary: gep problem when optimizer changes struct padding
           Product: libraries
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: robin at icir.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'm seeing a problem with the optimizer changing padding inside a
struct, but seemingly not propagating that change to a gep inside an
array.

Here's code to reproduce it. I'm using LLVM/clang 3.2.

----- r.ll

target triple = "x86_64-unknown-linux-gnu"

%A = type { i64, i32, i64 }

@B = constant i16 ptrtoint (i64* getelementptr (%A* null, i32 0, i32 2) to i16)
@C = constant [1 x { i16 }] [{ i16 } { i16 ptrtoint (i64* getelementptr (%A*
null, i32 0, i32 2) to i16) }]

----- r.c

#include <stdint.h>
#include <stdio.h>

extern const int16_t B;
extern const int16_t C[];

int main()
{
    printf("%d\n", B);
    printf("%d\n", C[0]);
}

-----

Without optimization, the offset of %A's 3rd element is 16:

# clang r.ll r.c -o a.out && ./a.out
16
16

With optimization enabled the offset changes to 12, however only B reflects
that:

# clang r.ll r.c -o a.out -O && ./a.out
12
16

Am I missing something, or is this bug?

-- 
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/20130413/67bd927c/attachment.html>


More information about the llvm-bugs mailing list