[llvm-commits] [llvm] r53261 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Dan Gohman
gohman at apple.com
Tue Jul 8 16:46:33 PDT 2008
Author: djg
Date: Tue Jul 8 18:46:32 2008
New Revision: 53261
URL: http://llvm.org/viewvc/llvm-project?rev=53261&view=rev
Log:
Factor out the code for computing an alignment value, and make it
available to getAtomic in addition to just getLoad and getStore,
to prevent MachineMemOperands with 0 alignment.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=53261&r1=53260&r2=53261&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Tue Jul 8 18:46:32 2008
@@ -654,6 +654,8 @@
void *&InsertPos);
void DeleteNodeNotInCSEMaps(SDNode *N);
+
+ unsigned getMVTAlignment(MVT MemoryVT) const;
// List of non-single value types.
std::list<std::vector<MVT> > VTList;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=53261&r1=53260&r2=53261&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Jul 8 18:46:32 2008
@@ -741,6 +741,16 @@
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
}
+/// getMVTAlignment - Compute the default alignment value for the
+/// given type.
+///
+unsigned SelectionDAG::getMVTAlignment(MVT VT) const {
+ const Type *Ty = VT == MVT::iPTR ?
+ PointerType::get(Type::Int8Ty, 0) :
+ VT.getTypeForMVT();
+
+ return TLI.getTargetData()->getABITypeAlignment(Ty);
+}
SelectionDAG::~SelectionDAG() {
while (!AllNodes.empty()) {
@@ -3069,7 +3079,13 @@
unsigned Alignment) {
assert(Opcode == ISD::ATOMIC_CMP_SWAP && "Invalid Atomic Op");
assert(Cmp.getValueType() == Swp.getValueType() && "Invalid Atomic Op Types");
- SDVTList VTs = getVTList(Cmp.getValueType(), MVT::Other);
+
+ MVT VT = Cmp.getValueType();
+
+ if (Alignment == 0) // Ensure that codegen never sees alignment 0
+ Alignment = getMVTAlignment(VT);
+
+ SDVTList VTs = getVTList(VT, MVT::Other);
FoldingSetNodeID ID;
SDOperand Ops[] = {Chain, Ptr, Cmp, Swp};
AddNodeIDNode(ID, Opcode, VTs, Ops, 4);
@@ -3094,7 +3110,13 @@
|| Opcode == ISD::ATOMIC_LOAD_MIN || Opcode == ISD::ATOMIC_LOAD_MAX
|| Opcode == ISD::ATOMIC_LOAD_UMIN || Opcode == ISD::ATOMIC_LOAD_UMAX)
&& "Invalid Atomic Op");
- SDVTList VTs = getVTList(Val.getValueType(), MVT::Other);
+
+ MVT VT = Val.getValueType();
+
+ if (Alignment == 0) // Ensure that codegen never sees alignment 0
+ Alignment = getMVTAlignment(VT);
+
+ SDVTList VTs = getVTList(VT, MVT::Other);
FoldingSetNodeID ID;
SDOperand Ops[] = {Chain, Ptr, Val};
AddNodeIDNode(ID, Opcode, VTs, Ops, 3);
@@ -3128,18 +3150,8 @@
SDOperand Ptr, SDOperand Offset,
const Value *SV, int SVOffset, MVT EVT,
bool isVolatile, unsigned Alignment) {
- if (Alignment == 0) { // Ensure that codegen never sees alignment 0
- const Type *Ty = 0;
- if (VT != MVT::iPTR) {
- Ty = VT.getTypeForMVT();
- } else if (SV) {
- const PointerType *PT = dyn_cast<PointerType>(SV->getType());
- assert(PT && "Value for load must be a pointer");
- Ty = PT->getElementType();
- }
- assert(Ty && "Could not get type information for load");
- Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
- }
+ if (Alignment == 0) // Ensure that codegen never sees alignment 0
+ Alignment = getMVTAlignment(VT);
if (VT == EVT) {
ExtType = ISD::NON_EXTLOAD;
@@ -3219,18 +3231,9 @@
bool isVolatile, unsigned Alignment) {
MVT VT = Val.getValueType();
- if (Alignment == 0) { // Ensure that codegen never sees alignment 0
- const Type *Ty = 0;
- if (VT != MVT::iPTR) {
- Ty = VT.getTypeForMVT();
- } else if (SV) {
- const PointerType *PT = dyn_cast<PointerType>(SV->getType());
- assert(PT && "Value for store must be a pointer");
- Ty = PT->getElementType();
- }
- assert(Ty && "Could not get type information for store");
- Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
- }
+ if (Alignment == 0) // Ensure that codegen never sees alignment 0
+ Alignment = getMVTAlignment(VT);
+
SDVTList VTs = getVTList(MVT::Other);
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
SDOperand Ops[] = { Chain, Val, Ptr, Undef };
@@ -3265,18 +3268,9 @@
assert(VT.isInteger() == SVT.isInteger() &&
"Can't do FP-INT conversion!");
- if (Alignment == 0) { // Ensure that codegen never sees alignment 0
- const Type *Ty = 0;
- if (VT != MVT::iPTR) {
- Ty = VT.getTypeForMVT();
- } else if (SV) {
- const PointerType *PT = dyn_cast<PointerType>(SV->getType());
- assert(PT && "Value for store must be a pointer");
- Ty = PT->getElementType();
- }
- assert(Ty && "Could not get type information for store");
- Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
- }
+ if (Alignment == 0) // Ensure that codegen never sees alignment 0
+ Alignment = getMVTAlignment(VT);
+
SDVTList VTs = getVTList(MVT::Other);
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
SDOperand Ops[] = { Chain, Val, Ptr, Undef };
More information about the llvm-commits
mailing list