[llvm] r174336 - [Stack Alignment] emit warning instead of a hard error

Manman Ren mren at apple.com
Mon Feb 4 17:35:19 PST 2013


Yes, there are related discussions in r169197 and "[PATCH] Stack Alignment: clamp the alignment of stack objects in MachineFrameInfo".

But people can use a 32-byte alignment attribute on a machine which only supports 16-byte stack alignment.
If the source code further assumes the low bits are zeros, they will get wrong result.
But if not, a hard error is too much and it will make existing code which can compile with earlier version failed to build with this patch.

Thanks,
Manman

On Feb 4, 2013, at 5:05 PM, Eric Christopher <echristo at gmail.com> wrote:

> Having been in this argument at least 2 times I'm curious what the logic is and since most of the list doesn't have access to radar... what's the reason? This seems like something that should probably be wider discussed.
> 
> -eric
> 
> 
> On Mon, Feb 4, 2013 at 3:45 PM, Manman Ren <mren at apple.com> wrote:
> Author: mren
> Date: Mon Feb  4 17:45:08 2013
> New Revision: 174336
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=174336&view=rev
> Log:
> [Stack Alignment] emit warning instead of a hard error
> 
> Per discussion in rdar://13127907, we should emit a hard error only if
> people write code where the requested alignment is larger than achievable
> and assumes the low bits are zeros. A warning should be good enough when
> we are not sure if the source code assumes the low bits are zeros.
> 
> rdar://13127907
> 
> Modified:
>     llvm/trunk/lib/CodeGen/MachineFunction.cpp
>     llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll
> 
> Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=174336&r1=174335&r2=174336&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Feb  4 17:45:08 2013
> @@ -479,11 +479,11 @@ static inline unsigned clampStackAlignme
>    if (!ShouldClamp || PrefAlign <= StackAlign)
>      return PrefAlign;
>    if (Alloca && MinAlign > StackAlign)
> -    Alloca->getParent()->getContext().emitError(Alloca,
> -        "Requested Minimal Alignment exceeds the Stack Alignment!");
> +    Alloca->getParent()->getContext().emitWarning(Alloca,
> +        "Requested alignment exceeds the stack alignment!");
>    else
>      assert(MinAlign <= StackAlign &&
> -           "Requested Minimal Alignment exceeds the Stack Alignment!");
> +           "Requested alignment exceeds the stack alignment!");
>    return StackAlign;
>  }
> 
> 
> Modified: llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll?rev=174336&r1=174335&r2=174336&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll Mon Feb  4 17:45:08 2013
> @@ -6,10 +6,10 @@
>  ; If alignment for alloc is smaller than or equal to stack alignment, but the
>  ; preferred type alignment is bigger, the alignment will be clamped.
>  ; If alignment for alloca is bigger than stack alignment, the compiler
> -; will emit an error.
> +; will emit a warning.
>  define void @test(<16 x float>* noalias sret %agg.result) nounwind ssp {
>  entry:
> -; CHECK: Requested Minimal Alignment exceeds the Stack Alignment!
> +; CHECK: warning: Requested alignment exceeds the stack alignment!
>   %retval = alloca <16 x float>, align 16
>   %0 = load <16 x float>* @T3_retval, align 16
>   store <16 x float> %0, <16 x float>* %retval
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130204/bd2d10a9/attachment.html>


More information about the llvm-commits mailing list