[llvm] r174741 - Revert 172027 and 174336. Remove diagnostics about over-aligned stack objects.

Bob Wilson bob.wilson at apple.com
Fri Feb 8 12:35:15 PST 2013


Author: bwilson
Date: Fri Feb  8 14:35:15 2013
New Revision: 174741

URL: http://llvm.org/viewvc/llvm-project?rev=174741&view=rev
Log:
Revert 172027 and 174336. Remove diagnostics about over-aligned stack objects.

Aside from the question of whether we report a warning or an error when we
can't satisfy a requested stack object alignment, the current implementation
of this is not good.  We're not providing any source location in the diagnostics
and the current warning is not connected to any warning group so you can't
control it.  We could improve the source location somewhat, but we can do a
much better job if this check is implemented in the front-end, so let's do that
instead.  <rdar://problem/13127907>

Removed:
    llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll
Modified:
    llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
    llvm/trunk/lib/CodeGen/MachineFunction.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign.ll

Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=174741&r1=174740&r2=174741&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Feb  8 14:35:15 2013
@@ -493,23 +493,11 @@ public:
     return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
   }
 
-  /// CreateStackObjectWithMinAlign - Create a new statically sized stack
-  /// object, returning a nonnegative identifier to represent it. This function
-  /// takes a preferred alignment and a minimal alignment.
-  ///
-  int CreateStackObjectWithMinAlign(uint64_t Size, unsigned PrefAlignment,
-                        unsigned MinAlignment, bool isSS,
-                        bool MayNeedSP = false, const AllocaInst *Alloca = 0);
-
   /// CreateStackObject - Create a new statically sized stack object, returning
-  /// a nonnegative identifier to represent it. Will not emit an error when
-  /// Alignment can't be satisfied.
+  /// a nonnegative identifier to represent it.
   ///
   int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
-                        bool MayNeedSP = false, const AllocaInst *Alloca = 0) {
-    return CreateStackObjectWithMinAlign(Size, Alignment, 0, isSS,
-                                         MayNeedSP, Alloca);
-  }
+                        bool MayNeedSP = false, const AllocaInst *Alloca = 0);
 
   /// CreateSpillStackObject - Create a new statically sized stack object that
   /// represents a spill slot, returning a nonnegative identifier to represent
@@ -529,8 +517,7 @@ public:
   /// variable sized object is created, whether or not the index returned is
   /// actually used.
   ///
-  int CreateVariableSizedObject(unsigned PrefAlignment, unsigned MinAlignment,
-                                const AllocaInst *Alloca = 0);
+  int CreateVariableSizedObject(unsigned Alignment);
 
   /// getCalleeSavedInfo - Returns a reference to call saved info vector for the
   /// current function.

Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=174741&r1=174740&r2=174741&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Feb  8 14:35:15 2013
@@ -466,32 +466,24 @@ void MachineFrameInfo::ensureMaxAlignmen
 }
 
 /// clampStackAlignment - Clamp the alignment if requested and emit a warning.
-static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned PrefAlign,
-                         unsigned MinAlign, unsigned StackAlign,
-                         const AllocaInst *Alloca = 0) {
-  if (!ShouldClamp || PrefAlign <= StackAlign)
-    return PrefAlign;
-  if (Alloca && MinAlign > StackAlign)
-    Alloca->getParent()->getContext().emitWarning(Alloca,
-        "Requested alignment exceeds the stack alignment!");
-  else
-    assert(MinAlign <= StackAlign &&
-           "Requested alignment exceeds the stack alignment!");
+static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned Align,
+                                           unsigned StackAlign) {
+  if (!ShouldClamp || Align <= StackAlign)
+    return Align;
+  DEBUG(dbgs() << "Warning: requested alignment " << Align
+               << " exceeds the stack alignment " << StackAlign
+               << " when stack realignment is off" << '\n');
   return StackAlign;
 }
 
-/// CreateStackObjectWithMinAlign - Create a new statically sized stack
-/// object, returning a nonnegative identifier to represent it. This function
-/// takes a preferred alignment and a minimal alignment.
+/// CreateStackObject - Create a new statically sized stack object, returning
+/// a nonnegative identifier to represent it.
 ///
-int MachineFrameInfo::CreateStackObjectWithMinAlign(uint64_t Size,
-                          unsigned PrefAlignment, unsigned MinAlignment,
-                          bool isSS, bool MayNeedSP, const AllocaInst *Alloca) {
+int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment,
+                      bool isSS, bool MayNeedSP, const AllocaInst *Alloca) {
   assert(Size != 0 && "Cannot allocate zero size stack objects!");
-  unsigned Alignment = clampStackAlignment(
-                           !TFI.isStackRealignable() || !RealignOption,
-                           PrefAlignment, MinAlignment,
-                           TFI.getStackAlignment(), Alloca);
+  Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
+                                  Alignment, TFI.getStackAlignment());
   Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP,
                                 Alloca));
   int Index = (int)Objects.size() - NumFixedObjects - 1;
@@ -507,8 +499,7 @@ int MachineFrameInfo::CreateStackObjectW
 int MachineFrameInfo::CreateSpillStackObject(uint64_t Size,
                                              unsigned Alignment) {
   Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
-                                  Alignment, 0,
-                                  TFI.getStackAlignment()); 
+                                  Alignment, TFI.getStackAlignment()); 
   CreateStackObject(Size, Alignment, true, false);
   int Index = (int)Objects.size() - NumFixedObjects - 1;
   ensureMaxAlignment(Alignment);
@@ -520,13 +511,10 @@ int MachineFrameInfo::CreateSpillStackOb
 /// variable sized object is created, whether or not the index returned is
 /// actually used.
 ///
-int MachineFrameInfo::CreateVariableSizedObject(unsigned PrefAlignment,
-                        unsigned MinAlignment, const AllocaInst *Alloca) {
+int MachineFrameInfo::CreateVariableSizedObject(unsigned Alignment) {
   HasVarSizedObjects = true;
-  unsigned Alignment = clampStackAlignment(
-                           !TFI.isStackRealignable() || !RealignOption,
-                           PrefAlignment, MinAlignment,
-                           TFI.getStackAlignment(), Alloca); 
+  Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
+                                  Alignment, TFI.getStackAlignment()); 
   Objects.push_back(StackObject(0, Alignment, 0, false, false, true, 0));
   ensureMaxAlignment(Alignment);
   return (int)Objects.size()-NumFixedObjects-1;
@@ -547,7 +535,7 @@ int MachineFrameInfo::CreateFixedObject(
   unsigned StackAlign = TFI.getStackAlignment();
   unsigned Align = MinAlign(SPOffset, StackAlign);
   Align = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
-                              Align, 0, TFI.getStackAlignment()); 
+                              Align, TFI.getStackAlignment()); 
   Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
                                               /*isSS*/   false,
                                               /*NeedSP*/ false,

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=174741&r1=174740&r2=174741&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Fri Feb  8 14:35:15 2013
@@ -95,8 +95,7 @@ void FunctionLoweringInfo::set(const Fun
            (TySize >= 8 && isa<ArrayType>(Ty) &&
             cast<ArrayType>(Ty)->getElementType()->isIntegerTy(8)));
         StaticAllocaMap[AI] =
-          MF->getFrameInfo()->CreateStackObjectWithMinAlign(TySize, Align,
-                                                AI->getAlignment(), false,
+          MF->getFrameInfo()->CreateStackObject(TySize, Align, false,
                                                 MayNeedSP, AI);
       }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=174741&r1=174740&r2=174741&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Feb  8 14:35:15 2013
@@ -3259,8 +3259,7 @@ void SelectionDAGBuilder::visitAlloca(co
 
   // Inform the Frame Information that we have just allocated a variable-sized
   // object.
-  FuncInfo.MF->getFrameInfo()->CreateVariableSizedObject(Align ? Align : 1,
-                                 I.getAlignment(), &I);
+  FuncInfo.MF->getFrameInfo()->CreateVariableSizedObject(Align ? Align : 1);
 }
 
 void SelectionDAGBuilder::visitLoad(const LoadInst &I) {

Removed: 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=174740&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign-error.ll (removed)
@@ -1,19 +0,0 @@
-; RUN: llc < %s -mtriple=armv7-apple-ios -O0 -realign-stack=0 2>&1 | FileCheck %s
-
-; rdar://12713765
- at T3_retval = common global <16 x float> zeroinitializer, align 16
-
-; 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 a warning.
-define void @test(<16 x float>* noalias sret %agg.result) nounwind ssp {
-entry:
-; 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
- %1 = load <16 x float>* %retval
- store <16 x float> %1, <16 x float>* %agg.result, align 16
- ret void
-}

Modified: llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign.ll?rev=174741&r1=174740&r2=174741&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/alloc-no-stack-realign.ll Fri Feb  8 14:35:15 2013
@@ -39,7 +39,7 @@ entry:
 ; NO-REALIGN: add [[R2:r[0-9]+]], [[R1:r[0-9]+]], #16
 ; NO-REALIGN: vst1.64
 ; NO-REALIGN: vst1.64
- %retval = alloca <16 x float>, align 4
+ %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
  %1 = load <16 x float>* %retval





More information about the llvm-commits mailing list