Skip to content

Commit b5d53ef

Browse files
committed
Only do the code-duplication fix.
1 parent ff7e17d commit b5d53ef

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

llvm/include/llvm/CodeGen/MachineFrameInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ class MachineFrameInfo {
638638
bool hasTailCall() const { return HasTailCall; }
639639
void setHasTailCall(bool V = true) { HasTailCall = V; }
640640

641-
/// Computes the maximum size of a callframe.
641+
/// Computes the maximum size of a callframe and the AdjustsStack property.
642642
/// This only works for targets defining
643643
/// TargetInstrInfo::getCallFrameSetupOpcode(), getCallFrameDestroyOpcode(),
644644
/// and getFrameSize().

llvm/lib/CodeGen/MachineFrameInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ void MachineFrameInfo::computeMaxCallFrameSize(
202202
AdjustsStack = true;
203203
if (FrameSDOps != nullptr)
204204
FrameSDOps->push_back(&MI);
205+
} else if (MI.isInlineAsm()) {
206+
// Some inline asm's need a stack frame, as indicated by operand 1.
207+
unsigned ExtraInfo = MI.getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
208+
if (ExtraInfo & InlineAsm::Extra_IsAlignStack)
209+
AdjustsStack = true;
205210
}
206211
}
207212
}

llvm/lib/CodeGen/PrologEpilogInserter.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
228228
FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF);
229229
ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
230230

231-
// Calculate the MaxCallFrameSize value for the function's frame
232-
// information. Also eliminates call frame pseudo instructions.
231+
// Calculate the MaxCallFrameSize and AdjustsStack variables for the
232+
// function's frame information. Also eliminates call frame pseudo
233+
// instructions.
233234
calculateCallFrameInfo(MF);
234235

235236
// Determine placement of CSR spill/restore code and prolog/epilog code:
@@ -349,8 +350,9 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
349350
return true;
350351
}
351352

352-
/// Calculate the MaxCallFrameSize variables for the function's frame
353-
/// information and eliminate call frame pseudo instructions.
353+
/// Calculate the MaxCallFrameSize and AdjustsStack
354+
/// variables for the function's frame information and eliminate call frame
355+
/// pseudo instructions.
354356
void PEI::calculateCallFrameInfo(MachineFunction &MF) {
355357
const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
356358
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
@@ -366,13 +368,13 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) {
366368
return;
367369

368370
// (Re-)Compute the MaxCallFrameSize with some sanity checks.
369-
bool WasComputed = MFI.isMaxCallFrameSizeComputed();
371+
bool CFSComputedIn = MFI.isMaxCallFrameSizeComputed();
370372
unsigned MaxCFSIn = MFI.getMaxCallFrameSize();
371373
bool AdjStackIn = MFI.adjustsStack();
372374
std::vector<MachineBasicBlock::iterator> FrameSDOps;
373375
MFI.computeMaxCallFrameSize(MF, &FrameSDOps);
374-
assert(!WasComputed || (MaxCFSIn >= MFI.getMaxCallFrameSize() &&
375-
!(!AdjStackIn && MFI.adjustsStack())));
376+
assert(!CFSComputedIn || (MaxCFSIn >= MFI.getMaxCallFrameSize() &&
377+
!(!AdjStackIn && MFI.adjustsStack())));
376378

377379
if (TFI->canSimplifyCallFramePseudos(MF)) {
378380
// If call frames are not being included as part of the stack frame, and

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,12 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
670670

671671
for (const auto &MI : MBB) {
672672
const MCInstrDesc &MCID = TII->get(MI.getOpcode());
673-
if ((MCID.isCall() && !MCID.isReturn()) || MI.isStackAligningInlineAsm())
673+
if ((MCID.isCall() && !MCID.isReturn()) ||
674+
MI.isStackAligningInlineAsm()) {
674675
MFI.setHasCalls(true);
676+
}
675677
if (MI.isInlineAsm()) {
676678
MF->setHasInlineAsm(true);
677-
if (MI.isStackAligningInlineAsm())
678-
MFI.setAdjustsStack(true);
679679
}
680680
}
681681
}

0 commit comments

Comments
 (0)