@@ -85,7 +85,6 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
85
85
TLI = MF->getSubtarget ().getTargetLowering ();
86
86
RegInfo = &MF->getRegInfo ();
87
87
const TargetFrameLowering *TFI = MF->getSubtarget ().getFrameLowering ();
88
- unsigned StackAlign = TFI->getStackAlignment ();
89
88
DA = DAG->getDivergenceAnalysis ();
90
89
91
90
// Check whether the function can return without sret-demotion.
@@ -130,19 +129,19 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
130
129
// Initialize the mapping of values to registers. This is only set up for
131
130
// instruction values that are used outside of the block that defines
132
131
// them.
132
+ const Align StackAlign = TFI->getStackAlign ();
133
133
for (const BasicBlock &BB : *Fn) {
134
134
for (const Instruction &I : BB) {
135
135
if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
136
136
Type *Ty = AI->getAllocatedType ();
137
- unsigned Align =
138
- std::max ((unsigned )MF->getDataLayout ().getPrefTypeAlignment (Ty),
139
- AI->getAlignment ());
137
+ Align Alignment =
138
+ max (MF->getDataLayout ().getPrefTypeAlign (Ty), AI->getAlign ());
140
139
141
140
// Static allocas can be folded into the initial stack frame
142
141
// adjustment. For targets that don't realign the stack, don't
143
142
// do this if there is an extra alignment requirement.
144
143
if (AI->isStaticAlloca () &&
145
- (TFI->isStackRealignable () || (Align <= StackAlign))) {
144
+ (TFI->isStackRealignable () || (Alignment <= StackAlign))) {
146
145
const ConstantInt *CUI = cast<ConstantInt>(AI->getArraySize ());
147
146
uint64_t TySize =
148
147
MF->getDataLayout ().getTypeAllocSize (Ty).getKnownMinSize ();
@@ -154,10 +153,10 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
154
153
if (Iter != CatchObjects.end () && TLI->needsFixedCatchObjects ()) {
155
154
FrameIndex = MF->getFrameInfo ().CreateFixedObject (
156
155
TySize, 0 , /* IsImmutable=*/ false , /* isAliased=*/ true );
157
- MF->getFrameInfo ().setObjectAlignment (FrameIndex, Align );
156
+ MF->getFrameInfo ().setObjectAlignment (FrameIndex, Alignment );
158
157
} else {
159
- FrameIndex =
160
- MF-> getFrameInfo (). CreateStackObject (TySize, Align, false , AI);
158
+ FrameIndex = MF-> getFrameInfo (). CreateStackObject (TySize, Alignment,
159
+ false , AI);
161
160
}
162
161
163
162
// Scalable vectors may need a special StackID to distinguish
@@ -176,10 +175,9 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
176
175
// FIXME: Overaligned static allocas should be grouped into
177
176
// a single dynamic allocation instead of using a separate
178
177
// stack allocation for each one.
179
- if (Align <= StackAlign)
180
- Align = 0 ;
181
178
// Inform the Frame Information that we have variable-sized objects.
182
- MF->getFrameInfo ().CreateVariableSizedObject (Align ? Align : 1 , AI);
179
+ MF->getFrameInfo ().CreateVariableSizedObject (
180
+ Alignment <= StackAlign ? 0 : Alignment.value (), AI);
183
181
}
184
182
}
185
183
0 commit comments