[PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 9 11:18:16 PDT 2016

rnk added a comment.

In https://reviews.llvm.org/D24378#538430, @efriedma wrote:

> This is probably going to lead to someone complaining about clang realigning the stack on 32-bit Windows; are your sure we're choosing the right alignment there?

I checked, and MSVC emits a call to __alloca_probe_16 for this code:

  extern "C" void *_alloca(size_t);
  #pragma intrinsic (_alloca)
  void g(void*);
  void f(int n) {
    void *p = _alloca(n);

So, they do realign the stack. We don't really need to realign the whole stack frame for highly aligned dynamic allocas, though. There's no reason we can't overallocate from the stack and realign the returned pointer. I'm not sure if we do that, though...


More information about the cfe-commits mailing list