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

           Summary: stack frame size is proportional to # of variables, even
                    if lifetimes don't overlap
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Created an attachment (id=3877)
 --> (http://llvm.org/bugs/attachment.cgi?id=3877)
Output of clang -O0 -S test.c at r89911

$ cat test.c
typedef struct BigStruct {
  char member[10000];
} BigStruct;

extern void use(BigStruct*);

void foo() {
  { BigStruct s; use(&s); }
  { BigStruct s; use(&s); }
}


With clang -O0 and -O3, this function uses 20000 bytes of stack space, even
though only one of the objects is alive at any given time. With gcc-4.4.1 -O0
and -O3, it only uses 10000 bytes (although I've seen C++ functions get gcc to
fail to reuse stack space too).

This can be a significant problem in programs with small stacks, especially in
C++ where we can have lots of invisible temporary objects. Because the small
stack problem exists in -O0 builds too, I don't think clang can get away with
only reusing stack space at -O>0.


-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to