[llvm-commits] [llvm-gcc-4.2] r108206 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Jim Grosbach
grosbach at apple.com
Mon Jul 12 17:02:14 PDT 2010
The diagnostic needs to be a bit broader than this, actually. It's not just the variable sized allocation that can't be dynamically aligned, but any declaration in the same function. That is, a function which has variable sized stack objects cannot also contain stack objects which require dynamic stack realignment.
-Jim
On Jul 12, 2010, at 4:02 PM, Eric Christopher wrote:
> Author: echristo
> Date: Mon Jul 12 18:02:56 2010
> New Revision: 108206
>
> URL: http://llvm.org/viewvc/llvm-project?rev=108206&view=rev
> Log:
> Make sure that the requested alignment isn't greater than the stack alignment
> for a vla - we won't adhere to it anyways so make it an error.
>
> Fixes rdar://7506902
>
> Modified:
> llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=108206&r1=108205&r2=108206&view=diff
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jul 12 18:02:56 2010
> @@ -39,6 +39,7 @@
> #include "llvm/Target/TargetLowering.h"
> #include "llvm/Target/TargetData.h"
> #include "llvm/Target/TargetMachine.h"
> +#include "llvm/Target/TargetFrameInfo.h"
> #include "llvm/ADT/StringExtras.h"
> #include "llvm/ADT/DenseMap.h"
>
> @@ -1755,6 +1756,15 @@
> if (isGimpleTemporary(decl))
> return;
>
> + /* If this is a vla type and we requested an alignment greater than the stack
> + alignment, error out since we're not going to dynamically realign
> + variable length array allocations. We're placing this here instead of
> + later in case it's a relatively unused variable. */
> + if (TREE_CODE (type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (type) &&
> + DECL_ALIGN(decl)/8u > TheTarget->getFrameInfo()->getStackAlignment())
> + error ("alignment for %q+D is greater than the stack alignment, "
> + "we cannot guarantee the alignment.", decl);
> +
> // If this is just the rotten husk of a variable that the gimplifier
> // eliminated all uses of, but is preserving for debug info, ignore it.
> if (TREE_CODE(decl) == VAR_DECL && DECL_VALUE_EXPR(decl))
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list