Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea64ee0

Browse files
committed
[Alignment][NFC] Deprecate ensureMaxAlignment
Summary: 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/D76368
1 parent 6a6a83c commit ea64ee0

File tree

8 files changed

+26
-12
lines changed

8 files changed

+26
-12
lines changed

llvm/include/llvm/CodeGen/CallingConvLower.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class CCState {
435435

436436
void ensureMaxAlignment(Align Alignment) {
437437
if (!AnalyzingMustTailForwardedRegs)
438-
MF.getFrameInfo().ensureMaxAlignment(Alignment.value());
438+
MF.getFrameInfo().ensureMaxAlignment(Alignment);
439439
}
440440

441441
/// Version of AllocateStack with extra register to be shadowed.

llvm/include/llvm/CodeGen/MachineFrameInfo.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class MachineFrameInfo {
484484

485485
// Only ensure max alignment for the default stack.
486486
if (getStackID(ObjectIdx) == 0)
487-
ensureMaxAlignment(Align);
487+
ensureMaxAlignment(assumeAligned(Align));
488488
}
489489

490490
/// setObjectAlignment - Change the alignment of the specified stack object.
@@ -594,7 +594,8 @@ class MachineFrameInfo {
594594
/// Make sure the function is at least Align bytes aligned.
595595
void ensureMaxAlignment(Align Alignment);
596596
/// FIXME: Remove this once transition to Align is over.
597-
inline void ensureMaxAlignment(unsigned Align) {
597+
LLVM_ATTRIBUTE_DEPRECATED(inline void ensureMaxAlignment(unsigned Align),
598+
"Use the version that uses Align instead") {
598599
ensureMaxAlignment(assumeAligned(Align));
599600
}
600601

llvm/include/llvm/CodeGen/TargetRegisterInfo.h

+6
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ class TargetRegisterInfo : public MCRegisterInfo {
285285
return getRegClassInfo(RC).SpillAlignment / 8;
286286
}
287287

288+
/// Return the minimum required alignment in bytes for a spill slot for
289+
/// a register of this class.
290+
Align getSpillAlign(const TargetRegisterClass &RC) const {
291+
return Align(getRegClassInfo(RC).SpillAlignment / 8);
292+
}
293+
288294
/// Return true if the given TargetRegisterClass has the ValueType T.
289295
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const {
290296
for (auto I = legalclasstypes_begin(RC); *I != MVT::Other; ++I)

llvm/include/llvm/IR/Function.h

+7
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ class Function : public GlobalObject, public ilist_node<Function> {
349349
return 0;
350350
}
351351

352+
/// Return the stack alignment for the function.
353+
MaybeAlign getFnStackAlign() const {
354+
if (!hasFnAttribute(Attribute::StackAlignment))
355+
return None;
356+
return AttributeSets.getStackAlignment(AttributeList::FunctionIndex);
357+
}
358+
352359
/// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
353360
/// to use during code generation.
354361
bool hasGC() const {

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
654654
MFI.setStackSize(YamlMFI.StackSize);
655655
MFI.setOffsetAdjustment(YamlMFI.OffsetAdjustment);
656656
if (YamlMFI.MaxAlignment)
657-
MFI.ensureMaxAlignment(YamlMFI.MaxAlignment);
657+
MFI.ensureMaxAlignment(Align(YamlMFI.MaxAlignment));
658658
MFI.setAdjustsStack(YamlMFI.AdjustsStack);
659659
MFI.setHasCalls(YamlMFI.HasCalls);
660660
if (YamlMFI.MaxCallFrameSize != ~0u)

llvm/lib/CodeGen/MachineFunction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void MachineFunction::init() {
172172
F.hasFnAttribute(Attribute::StackAlignment));
173173

174174
if (F.hasFnAttribute(Attribute::StackAlignment))
175-
FrameInfo->ensureMaxAlignment(F.getFnStackAlignment());
175+
FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
176176

177177
ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
178178
Alignment = STI->getTargetLowering()->getMinFunctionAlignment();

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
432432
DAG.getCopyFromReg(Chain, dl, HRI.getStackRegister(), PtrVT);
433433

434434
bool NeedsArgAlign = false;
435-
unsigned LargestAlignSeen = 0;
435+
Align LargestAlignSeen;
436436
// Walk the register/memloc assignments, inserting copies/loads.
437437
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
438438
CCValAssign &VA = ArgLocs[i];
@@ -469,8 +469,8 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
469469
StackPtr.getValueType());
470470
MemAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, MemAddr);
471471
if (ArgAlign)
472-
LargestAlignSeen = std::max(LargestAlignSeen,
473-
(unsigned)VA.getLocVT().getStoreSizeInBits() >> 3);
472+
LargestAlignSeen = std::max(
473+
LargestAlignSeen, Align(VA.getLocVT().getStoreSizeInBits() / 8));
474474
if (Flags.isByVal()) {
475475
// The argument is a struct passed by value. According to LLVM, "Arg"
476476
// is a pointer.
@@ -493,7 +493,7 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
493493

494494
if (NeedsArgAlign && Subtarget.hasV60Ops()) {
495495
LLVM_DEBUG(dbgs() << "Function needs byte stack align due to call args\n");
496-
unsigned VecAlign = HRI.getSpillAlignment(Hexagon::HvxVRRegClass);
496+
Align VecAlign(HRI.getSpillAlignment(Hexagon::HvxVRRegClass));
497497
LargestAlignSeen = std::max(LargestAlignSeen, VecAlign);
498498
MFI.ensureMaxAlignment(LargestAlignSeen);
499499
}

llvm/lib/Target/X86/X86FrameLowering.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2229,16 +2229,16 @@ bool X86FrameLowering::assignCalleeSavedSpillSlots(
22292229

22302230
const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg, VT);
22312231
unsigned Size = TRI->getSpillSize(*RC);
2232-
unsigned Align = TRI->getSpillAlignment(*RC);
2232+
Align Alignment = TRI->getSpillAlign(*RC);
22332233
// ensure alignment
22342234
assert(SpillSlotOffset < 0 && "SpillSlotOffset should always < 0 on X86");
2235-
SpillSlotOffset = -alignTo(-SpillSlotOffset, Align);
2235+
SpillSlotOffset = -alignTo(-SpillSlotOffset, Alignment);
22362236

22372237
// spill into slot
22382238
SpillSlotOffset -= Size;
22392239
int SlotIndex = MFI.CreateFixedSpillStackObject(Size, SpillSlotOffset);
22402240
CSI[i - 1].setFrameIdx(SlotIndex);
2241-
MFI.ensureMaxAlignment(Align);
2241+
MFI.ensureMaxAlignment(Alignment);
22422242

22432243
// Save the start offset and size of XMM in stack frame for funclets.
22442244
if (X86::VR128RegClass.contains(Reg)) {

0 commit comments

Comments
 (0)