[llvm] ef150e2 - [Hexagon] Update PS_aligna with max stack alignment once isel completes
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 09:48:41 PST 2019
Author: Krzysztof Parzyszek
Date: 2019-11-12T11:47:29-06:00
New Revision: ef150e2ea51960e4a9689850d16b2dda355cdcd8
URL: https://github.com/llvm/llvm-project/commit/ef150e2ea51960e4a9689850d16b2dda355cdcd8
DIFF: https://github.com/llvm/llvm-project/commit/ef150e2ea51960e4a9689850d16b2dda355cdcd8.diff
LOG: [Hexagon] Update PS_aligna with max stack alignment once isel completes
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
index 4684d8e4781a..1129f17b8729 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
@@ -1261,7 +1261,7 @@ void HexagonDAGToDAGISel::PreprocessISelDAG() {
}
void HexagonDAGToDAGISel::EmitFunctionEntryCode() {
- auto &HST = static_cast<const HexagonSubtarget&>(MF->getSubtarget());
+ auto &HST = MF->getSubtarget<HexagonSubtarget>();
auto &HFI = *HST.getFrameLowering();
if (!HFI.needsAligna(*MF))
return;
@@ -1269,12 +1269,23 @@ void HexagonDAGToDAGISel::EmitFunctionEntryCode() {
MachineFrameInfo &MFI = MF->getFrameInfo();
MachineBasicBlock *EntryBB = &MF->front();
unsigned AR = FuncInfo->CreateReg(MVT::i32);
- unsigned MaxA = MFI.getMaxAlignment();
+ unsigned EntryMaxA = MFI.getMaxAlignment();
BuildMI(EntryBB, DebugLoc(), HII->get(Hexagon::PS_aligna), AR)
- .addImm(MaxA);
+ .addImm(EntryMaxA);
MF->getInfo<HexagonMachineFunctionInfo>()->setStackAlignBaseVReg(AR);
}
+void HexagonDAGToDAGISel::updateAligna() {
+ auto &HFI = *MF->getSubtarget<HexagonSubtarget>().getFrameLowering();
+ if (!HFI.needsAligna(*MF))
+ return;
+ auto *AlignaI = const_cast<MachineInstr*>(HFI.getAlignaInstr(*MF));
+ assert(AlignaI != nullptr);
+ unsigned MaxA = MF->getFrameInfo().getMaxAlignment();
+ if (AlignaI->getOperand(1).getImm() < MaxA)
+ AlignaI->getOperand(1).setImm(MaxA);
+}
+
// Match a frame index that can be used in an addressing mode.
bool HexagonDAGToDAGISel::SelectAddrFI(SDValue &N, SDValue &R) {
if (N.getOpcode() != ISD::FrameIndex)
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h
index 65edb09603b3..6c77d8803359 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h
@@ -43,6 +43,7 @@ class HexagonDAGToDAGISel : public SelectionDAGISel {
HII = HST->getInstrInfo();
HRI = HST->getRegisterInfo();
SelectionDAGISel::runOnMachineFunction(MF);
+ updateAligna();
return true;
}
@@ -144,6 +145,9 @@ class HexagonDAGToDAGISel : public SelectionDAGISel {
void ppAddrRewriteAndSrl(std::vector<SDNode*> &&Nodes);
void ppHoistZextI1(std::vector<SDNode*> &&Nodes);
+ // Function postprocessing.
+ void updateAligna();
+
SmallDenseMap<SDNode *,int> RootWeights;
SmallDenseMap<SDNode *,int> RootHeights;
SmallDenseMap<const Value *,int> GAUsesInFunction;
More information about the llvm-commits
mailing list