Only fixed stack objects and spill slots should be get FixedStack PseudoSourceValue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84411 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 7138dd2..0adffbb 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -639,11 +639,9 @@
EVT PtrVT = TLI.getPointerTy();
SDValue StackPtr = DAG.CreateStackTemporary(VT);
- int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
-
// Store the vector.
SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Tmp1, StackPtr,
- PseudoSourceValue::getFixedStack(SPFI), 0);
+ PseudoSourceValue::getStack(), 0);
// Truncate or zero extend offset to target pointer type.
unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND;
@@ -654,10 +652,10 @@
SDValue StackPtr2 = DAG.getNode(ISD::ADD, dl, IdxVT, Tmp3, StackPtr);
// Store the scalar value.
Ch = DAG.getTruncStore(Ch, dl, Tmp2, StackPtr2,
- PseudoSourceValue::getFixedStack(SPFI), 0, EltVT);
+ PseudoSourceValue::getStack(), 0, EltVT);
// Load the updated vector.
return DAG.getLoad(VT, dl, Ch, StackPtr,
- PseudoSourceValue::getFixedStack(SPFI), 0);
+ PseudoSourceValue::getStack(), 0);
}
@@ -1517,8 +1515,7 @@
EVT OpVT = Node->getOperand(0).getValueType();
DebugLoc dl = Node->getDebugLoc();
SDValue FIPtr = DAG.CreateStackTemporary(VT);
- int FI = cast<FrameIndexSDNode>(FIPtr.getNode())->getIndex();
- const Value *SV = PseudoSourceValue::getFixedStack(FI);
+ const Value *SV = PseudoSourceValue::getStack();
// Emit a store of each element to the stack slot.
SmallVector<SDValue, 8> Stores;
@@ -1712,20 +1709,17 @@
getTypeForEVT(*DAG.getContext()));
SDValue FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign);
- FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr);
- int SPFI = StackPtrFI->getIndex();
- const Value *SV = PseudoSourceValue::getFixedStack(SPFI);
-
unsigned SrcSize = SrcOp.getValueType().getSizeInBits();
unsigned SlotSize = SlotVT.getSizeInBits();
unsigned DestSize = DestVT.getSizeInBits();
unsigned DestAlign =
- TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForEVT(*DAG.getContext()));
+ TLI.getTargetData()->getPrefTypeAlignment(DestVT.
+ getTypeForEVT(*DAG.getContext()));
// Emit a store to the stack slot. Use a truncstore if the input value is
// later than DestVT.
SDValue Store;
-
+ const Value *SV = PseudoSourceValue::getStack();
if (SrcSize > SlotSize)
Store = DAG.getTruncStore(DAG.getEntryNode(), dl, SrcOp, FIPtr,
SV, 0, SlotVT, false, SrcAlign);
@@ -1750,15 +1744,12 @@
// then load the whole vector back out.
SDValue StackPtr = DAG.CreateStackTemporary(Node->getValueType(0));
- FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(StackPtr);
- int SPFI = StackPtrFI->getIndex();
-
SDValue Ch = DAG.getTruncStore(DAG.getEntryNode(), dl, Node->getOperand(0),
StackPtr,
- PseudoSourceValue::getFixedStack(SPFI), 0,
+ PseudoSourceValue::getStack(), 0,
Node->getValueType(0).getVectorElementType());
return DAG.getLoad(Node->getValueType(0), dl, Ch, StackPtr,
- PseudoSourceValue::getFixedStack(SPFI), 0);
+ PseudoSourceValue::getStack(), 0);
}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
index dbd3e39..29f1a2d 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
@@ -118,8 +118,7 @@
TLI.getTargetData()->getPrefTypeAlignment(NOutVT.
getTypeForEVT(*DAG.getContext()));
SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment);
- int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
- const Value *SV = PseudoSourceValue::getFixedStack(SPFI);
+ const Value *SV = PseudoSourceValue::getStack();
// Emit a store to the stack slot.
SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, InOp, StackPtr, SV, 0);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 75e1239..1964f64 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -1057,8 +1057,7 @@
EVT EltVT = VecVT.getVectorElementType();
DebugLoc dl = N->getDebugLoc();
SDValue StackPtr = DAG.CreateStackTemporary(VecVT);
- int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
- const Value *SV = PseudoSourceValue::getFixedStack(SPFI);
+ const Value *SV = PseudoSourceValue::getStack();
SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, SV, 0);
// Load back the required element.
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 8bd0370..cd7e1fd 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3507,16 +3507,22 @@
SDValue Ptr, SDValue Cmp,
SDValue Swp, const Value* PtrVal,
unsigned Alignment) {
+ MachineFunction &MF = getMachineFunction();
+ MachineFrameInfo *FrameInfo = MF.getFrameInfo();
+
if (Alignment == 0) // Ensure that codegen never sees alignment 0
Alignment = getEVTAlignment(MemVT);
// Check if the memory reference references a frame index
if (!PtrVal)
if (const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
- PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex());
+ dyn_cast<const FrameIndexSDNode>(Ptr.getNode())) {
+ if (FrameInfo->isFixedObjectIndex(FI->getIndex()))
+ PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex());
+ else
+ PtrVal = PseudoSourceValue::getStack();
+ }
- MachineFunction &MF = getMachineFunction();
unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
// For now, atomics are considered to be volatile always.
@@ -3560,16 +3566,21 @@
SDValue Ptr, SDValue Val,
const Value* PtrVal,
unsigned Alignment) {
+ MachineFunction &MF = getMachineFunction();
+ MachineFrameInfo *FrameInfo = MF.getFrameInfo();
+
if (Alignment == 0) // Ensure that codegen never sees alignment 0
Alignment = getEVTAlignment(MemVT);
// Check if the memory reference references a frame index
if (!PtrVal)
if (const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
- PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex());
+ dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
+ if (FrameInfo->isFixedObjectIndex(FI->getIndex()))
+ PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex());
+ else
+ PtrVal = PseudoSourceValue::getStack();
- MachineFunction &MF = getMachineFunction();
unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
// For now, atomics are considered to be volatile always.
@@ -3707,16 +3718,21 @@
SDValue Ptr, SDValue Offset,
const Value *SV, int SVOffset, EVT MemVT,
bool isVolatile, unsigned Alignment) {
+ MachineFunction &MF = getMachineFunction();
+ MachineFrameInfo *FrameInfo = MF.getFrameInfo();
+
if (Alignment == 0) // Ensure that codegen never sees alignment 0
Alignment = getEVTAlignment(VT);
// Check if the memory reference references a frame index
if (!SV)
if (const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
- SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
+ if (FrameInfo->isFixedObjectIndex(FI->getIndex()))
+ SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ else
+ SV = PseudoSourceValue::getStack();
- MachineFunction &MF = getMachineFunction();
unsigned Flags = MachineMemOperand::MOLoad;
if (isVolatile)
Flags |= MachineMemOperand::MOVolatile;
@@ -3806,16 +3822,21 @@
SDValue SelectionDAG::getStore(SDValue Chain, DebugLoc dl, SDValue Val,
SDValue Ptr, const Value *SV, int SVOffset,
bool isVolatile, unsigned Alignment) {
+ MachineFunction &MF = getMachineFunction();
+ MachineFrameInfo *FrameInfo = MF.getFrameInfo();
+
if (Alignment == 0) // Ensure that codegen never sees alignment 0
Alignment = getEVTAlignment(Val.getValueType());
// Check if the memory reference references a frame index
if (!SV)
if (const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
- SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
+ if (FrameInfo->isFixedObjectIndex(FI->getIndex()))
+ SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ else
+ SV = PseudoSourceValue::getStack();
- MachineFunction &MF = getMachineFunction();
unsigned Flags = MachineMemOperand::MOStore;
if (isVolatile)
Flags |= MachineMemOperand::MOVolatile;
@@ -3852,16 +3873,21 @@
SDValue Ptr, const Value *SV,
int SVOffset, EVT SVT,
bool isVolatile, unsigned Alignment) {
+ MachineFunction &MF = getMachineFunction();
+ MachineFrameInfo *FrameInfo = MF.getFrameInfo();
+
if (Alignment == 0) // Ensure that codegen never sees alignment 0
Alignment = getEVTAlignment(SVT);
// Check if the memory reference references a frame index
if (!SV)
if (const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
- SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ dyn_cast<const FrameIndexSDNode>(Ptr.getNode()))
+ if (FrameInfo->isFixedObjectIndex(FI->getIndex()))
+ SV = PseudoSourceValue::getFixedStack(FI->getIndex());
+ else
+ SV = PseudoSourceValue::getStack();
- MachineFunction &MF = getMachineFunction();
unsigned Flags = MachineMemOperand::MOStore;
if (isVolatile)
Flags |= MachineMemOperand::MOVolatile;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index adcc532..9c22202 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -4196,9 +4196,11 @@
SDValue FIN = DAG.getFrameIndex(FI, PtrTy);
// Store the stack protector onto the stack.
+ const Value *SV = MFI->isFixedObjectIndex(FI)
+ ? PseudoSourceValue::getFixedStack(FI)
+ : PseudoSourceValue::getStack();
SDValue Result = DAG.getStore(getRoot(), getCurDebugLoc(), Src, FIN,
- PseudoSourceValue::getFixedStack(FI),
- 0, true);
+ SV, 0, true);
setValue(&I, Result);
DAG.setRoot(Result);
return 0;