Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lib/Target/X86/X86CallFrameOptimization.cpp
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) { | ||||
SlotSize = RegInfo.getSlotSize(); | SlotSize = RegInfo.getSlotSize(); | ||||
assert(isPowerOf2_32(SlotSize) && "Expect power of 2 stack slot size"); | assert(isPowerOf2_32(SlotSize) && "Expect power of 2 stack slot size"); | ||||
Log2SlotSize = Log2_32(SlotSize); | Log2SlotSize = Log2_32(SlotSize); | ||||
if (skipFunction(*MF.getFunction()) || !isLegal(MF)) | if (skipFunction(*MF.getFunction()) || !isLegal(MF)) | ||||
return false; | return false; | ||||
unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode(); | unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode(); | ||||
thegameg: Looks like this is already called in `PEI::insertPrologEpilogCode`, which sounds like a better… | |||||
Not Done ReplyInline ActionsYou are right. This was needed for previous version of the patch, and I haven't removed it. This pass runs before PEI and needed to have initial values set, because cfa offset and cfa adjustment were both contained in cfa offset field (in the previous patch). Now that they are apart, and because this pass adds only adjust_cfa_offset directives, this initialization is no longer needed here; absolute cfa offsets can be initialized in PEI. violetav: You are right. This was needed for previous version of the patch, and I haven't removed it. | |||||
bool Changed = false; | bool Changed = false; | ||||
ContextVector CallSeqVector; | ContextVector CallSeqVector; | ||||
for (auto &MBB : MF) | for (auto &MBB : MF) | ||||
for (auto &MI : MBB) | for (auto &MI : MBB) | ||||
if (MI.getOpcode() == FrameSetupOpcode) { | if (MI.getOpcode() == FrameSetupOpcode) { | ||||
CallContext Context; | CallContext Context; | ||||
▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | case X86::MOV64mr: { | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// For debugging, when using SP-based CFA, we need to adjust the CFA | // For debugging, when using SP-based CFA, we need to adjust the CFA | ||||
// offset after each push. | // offset after each push. | ||||
// TODO: This is needed only if we require precise CFA. | // TODO: This is needed only if we require precise CFA. | ||||
if (!TFL->hasFP(MF)) | if (!TFL->hasFP(MF)) { | ||||
TFL->BuildCFI( | TFL->BuildCFI(MBB, std::next(Push), DL, | ||||
MBB, std::next(Push), DL, | |||||
MCCFIInstruction::createAdjustCfaOffset(nullptr, SlotSize)); | MCCFIInstruction::createAdjustCfaOffset(nullptr, SlotSize)); | ||||
// Update the CFI information for MBB and it's successors. | |||||
MBB.updateCFIInfo(std::next(Push)); | |||||
MBB.updateCFIInfoSucc(); | |||||
} | |||||
MBB.erase(MOV); | MBB.erase(MOV); | ||||
} | } | ||||
// The stack-pointer copy is no longer used in the call sequences. | // The stack-pointer copy is no longer used in the call sequences. | ||||
// There should not be any other users, but we can't commit to that, so: | // There should not be any other users, but we can't commit to that, so: | ||||
if (Context.SPCopy && MRI->use_empty(Context.SPCopy->getOperand(0).getReg())) | if (Context.SPCopy && MRI->use_empty(Context.SPCopy->getOperand(0).getReg())) | ||||
Context.SPCopy->eraseFromParent(); | Context.SPCopy->eraseFromParent(); | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
Looks like this is already called in PEI::insertPrologEpilogCode, which sounds like a better idea than having it in target specific passes.