]> granicus.if.org Git - llvm/commitdiff
[Alignment] Get DataLayout::StackAlignment as Align
authorGuillaume Chatelet <gchatelet@google.com>
Mon, 23 Sep 2019 12:01:32 +0000 (12:01 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Mon, 23 Sep 2019 12:01:32 +0000 (12:01 +0000)
Summary:
Internally it is needed to know if StackAlignment is set but we can
expose it as llvm::Align.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67852

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372585 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DataLayout.h
lib/Target/AArch64/AArch64CallingConvention.cpp
lib/Target/ARM/ARMCallingConv.cpp
lib/Target/ARM/ARMISelLowering.cpp

index b40a44cfaab12cd4b6dd0462c8e3bfadffd3a229..630a92ec3be3fbc9747fa69d9e01e3f710f35f2c 100644 (file)
@@ -266,7 +266,11 @@ public:
     return StackNaturalAlign && (Align > StackNaturalAlign);
   }
 
-  unsigned getStackAlignment() const { return StackNaturalAlign ? StackNaturalAlign->value() : 0; }
+  llvm::Align getStackAlignment() const {
+    assert(StackNaturalAlign && "StackNaturalAlign must be defined");
+    return *StackNaturalAlign;
+  }
+
   unsigned getAllocaAddrSpace() const { return AllocaAddrSpace; }
 
   /// Returns the alignment of function pointers, which may or may not be
index 39f42562d5498c4283f109fa0736ced3328a9aa1..455300260d1cb23fe0a794855ef3ecccd5cda7e1 100644 (file)
@@ -40,12 +40,14 @@ static bool finishStackBlock(SmallVectorImpl<CCValAssign> &PendingMembers,
                              MVT LocVT, ISD::ArgFlagsTy &ArgFlags,
                              CCState &State, unsigned SlotAlign) {
   unsigned Size = LocVT.getSizeInBits() / 8;
-  unsigned StackAlign =
+  const llvm::Align StackAlign =
       State.getMachineFunction().getDataLayout().getStackAlignment();
-  unsigned Align = std::min(ArgFlags.getOrigAlign(), StackAlign);
+  const llvm::Align OrigAlign(ArgFlags.getOrigAlign());
+  const llvm::Align Align = std::min(OrigAlign, StackAlign);
 
   for (auto &It : PendingMembers) {
-    It.convertToMem(State.AllocateStack(Size, std::max(Align, SlotAlign)));
+    It.convertToMem(State.AllocateStack(
+        Size, std::max((unsigned)Align.value(), SlotAlign)));
     State.addLoc(It);
     SlotAlign = 1;
   }
index 5ede7c67f7c2ea3443386805e02c469c1acabd4e..92ebc542b423b2c01fce6defccb4cb065c34f6e6 100644 (file)
@@ -193,7 +193,7 @@ static bool CC_ARM_AAPCS_Custom_Aggregate(unsigned &ValNo, MVT &ValVT,
   // Try to allocate a contiguous block of registers, each of the correct
   // size to hold one member.
   auto &DL = State.getMachineFunction().getDataLayout();
-  unsigned StackAlign = DL.getStackAlignment();
+  unsigned StackAlign = DL.getStackAlignment().value();
   unsigned Align = std::min(PendingMembers[0].getExtraInfo(), StackAlign);
 
   ArrayRef<MCPhysReg> RegList;
index fbcdbbc2d0a293b9472e3a8459c03e5f6aee3e3f..60d81ee034035fbe79dc88944c958a343048436a 100644 (file)
@@ -16771,7 +16771,8 @@ ARMTargetLowering::getABIAlignmentForCallingConv(Type *ArgTy,
 
   // Avoid over-aligning vector parameters. It would require realigning the
   // stack and waste space for no real benefit.
-  return std::min(DL.getABITypeAlignment(ArgTy), DL.getStackAlignment());
+  return std::min(DL.getABITypeAlignment(ArgTy),
+                  (unsigned)DL.getStackAlignment().value());
 }
 
 /// Return true if a type is an AAPCS-VFP homogeneous aggregate or one of