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 228 Lines • ▼ Show 20 Lines | bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) { | ||||
MRI = &MF.getRegInfo(); | MRI = &MF.getRegInfo(); | ||||
const X86RegisterInfo &RegInfo = | const X86RegisterInfo &RegInfo = | ||||
*static_cast<const X86RegisterInfo *>(STI->getRegisterInfo()); | *static_cast<const X86RegisterInfo *>(STI->getRegisterInfo()); | ||||
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); | ||||
// Set initial incoming and outgoing cfa offset and register values for basic | |||||
// blocks. This is done here because this pass runs before PEI and can insert | |||||
// CFI instructions. | |||||
// TODO: Find a better solution to this problem. | |||||
TFL->initializeCFIInfo(MF); | |||||
thegameg: Looks like this is already called in `PEI::insertPrologEpilogCode`, which sounds like a better… | |||||
violetavAuthorUnsubmitted 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. | |||||
if (skipFunction(*MF.getFunction()) || !isLegal(MF)) | if (skipFunction(*MF.getFunction()) || !isLegal(MF)) | ||||
return false; | return false; | ||||
unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode(); | unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode(); | ||||
bool Changed = false; | bool Changed = false; | ||||
ContextVector CallSeqVector; | ContextVector CallSeqVector; | ||||
▲ Show 20 Lines • Show All 286 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.