[LLVMbugs] [Bug 1532] NEW: Alignment too big with alloca in C/C++ frontend

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Jul 2 10:16:40 PDT 2007


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

           Summary: Alignment too big with alloca in C/C++ frontend
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: loufoque at gmail.com


The following C code

struct test
{
    int a;
    char b;
};

void do_something(struct test*);

int main()
{
    struct test t;
    do_something(&t);
}

generates an alloca instruction with an alignment of 8 on the web demo.
However, the type "struct test" only requires an alignment of 4 for the x86 target.
I think it shouldn't even be specified here, because the type definition is
enough to know the required alignment.

Actual output:

; ModuleID = '/tmp/webcompile/_31500_0.bc'
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"
target triple = "i686-pc-linux-gnu"
	%struct.test = type { i32, i8 }

define i32 @main() {
entry:
	%t = alloca %struct.test, align 8		; <%struct.test*> [#uses=1]
	call void @do_something( %struct.test* %t )
	ret i32 undef
}

declare void @do_something(%struct.test*)

Expected output:

; ModuleID = '/tmp/webcompile/_31500_0.bc'
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"
target triple = "i686-pc-linux-gnu"
	%struct.test = type { i32, i8 }

define i32 @main() {
entry:
	%t = alloca %struct.test		; <%struct.test*> [#uses=1]
	call void @do_something( %struct.test* %t )
	ret i32 undef
}

declare void @do_something(%struct.test*)



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list