[llvm] r372585 - [Alignment] Get DataLayout::StackAlignment as Align
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 05:01:32 PDT 2019
Author: gchatelet
Date: Mon Sep 23 05:01:32 2019
New Revision: 372585
URL: http://llvm.org/viewvc/llvm-project?rev=372585&view=rev
Log:
[Alignment] Get DataLayout::StackAlignment as Align
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
Modified:
llvm/trunk/include/llvm/IR/DataLayout.h
llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.cpp
llvm/trunk/lib/Target/ARM/ARMCallingConv.cpp
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
Modified: llvm/trunk/include/llvm/IR/DataLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DataLayout.h?rev=372585&r1=372584&r2=372585&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DataLayout.h (original)
+++ llvm/trunk/include/llvm/IR/DataLayout.h Mon Sep 23 05:01:32 2019
@@ -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
Modified: llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.cpp?rev=372585&r1=372584&r2=372585&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.cpp Mon Sep 23 05:01:32 2019
@@ -40,12 +40,14 @@ static bool finishStackBlock(SmallVector
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;
}
Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.cpp?rev=372585&r1=372584&r2=372585&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMCallingConv.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMCallingConv.cpp Mon Sep 23 05:01:32 2019
@@ -193,7 +193,7 @@ static bool CC_ARM_AAPCS_Custom_Aggregat
// 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;
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=372585&r1=372584&r2=372585&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Sep 23 05:01:32 2019
@@ -16771,7 +16771,8 @@ ARMTargetLowering::getABIAlignmentForCal
// 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
More information about the llvm-commits
mailing list