diff options
author | Evan Cheng <evan.cheng@apple.com> | 2011-11-28 22:37:34 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2011-11-28 22:37:34 +0000 |
commit | 4a5b2040e20295e0f03fdbf15609ad5c137a6e3a (patch) | |
tree | 362215e659c0ff66ea18119a1e35c85fd617ee6e /llvm/lib/CodeGen/SelectionDAG | |
parent | 124d8ff0da2d83353b4a6c5a59397113ad18e8b4 (diff) | |
download | bcm5719-llvm-4a5b2040e20295e0f03fdbf15609ad5c137a6e3a.tar.gz bcm5719-llvm-4a5b2040e20295e0f03fdbf15609ad5c137a6e3a.zip |
Revert r145273 and fix in SelectionDAG::InferPtrAlignment() instead.
Conservatively returns zero when the GV does not specify an alignment nor is it
initialized. Previously it returns ABI alignment for type of the GV. However, if
the type is a "packed" type, then the under-specified alignments is attached to
the load / store instructions. In that case, the alignment of the type cannot be
trusted.
rdar://10464621
llvm-svn: 145300
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 38 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 6 |
2 files changed, 17 insertions, 27 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 2c4886a3c83..d8208a44338 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6206,20 +6206,13 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) { // Try to infer better alignment information than the load already has. if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) { - unsigned ABIAlign = TLI.getTargetData()-> - getABITypeAlignment(LD->getMemoryVT().getTypeForEVT(*DAG.getContext())); - unsigned LDAlign = LD->getAlignment(); - // Do not touch loads with explicit alignments that are smaller than ABI - // alignment to avoid breaking loads from "packed" types. - if (!LDAlign || LDAlign >= ABIAlign) { - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { - if (Align > LDAlign) - return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(), - LD->getValueType(0), - Chain, Ptr, LD->getPointerInfo(), - LD->getMemoryVT(), - LD->isVolatile(), LD->isNonTemporal(), Align); - } + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { + if (Align > LD->getAlignment()) + return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(), + LD->getValueType(0), + Chain, Ptr, LD->getPointerInfo(), + LD->getMemoryVT(), + LD->isVolatile(), LD->isNonTemporal(), Align); } } @@ -6676,18 +6669,11 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { // Try to infer better alignment information than the store already has. if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { - unsigned ABIAlign = TLI.getTargetData()-> - getABITypeAlignment(ST->getMemoryVT().getTypeForEVT(*DAG.getContext())); - unsigned STAlign = ST->getAlignment(); - // Do not touch stores with explicit alignments that are smaller than ABI - // alignment to avoid breaking stores from "packed" types. - if (!STAlign || STAlign >= ABIAlign) { - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { - if (Align > STAlign) - return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, - Ptr, ST->getPointerInfo(), ST->getMemoryVT(), - ST->isVolatile(), ST->isNonTemporal(),Align); - } + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { + if (Align > ST->getAlignment()) + return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, + Ptr, ST->getPointerInfo(), ST->getMemoryVT(), + ST->isVolatile(), ST->isNonTemporal(), Align); } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a772a46ba60..024a1637371 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -6564,7 +6564,11 @@ unsigned SelectionDAG::InferPtrAlignment(SDValue Ptr) const { } } if (!Align) - Align = TLI.getTargetData()->getABITypeAlignment(GV->getType()); + // Conservatively returns zero here instead of using ABI alignment for + // type of the GV. If the type is a "packed" type, then the under- + // specified alignments is attached to the load / store instructions. + // In that case, the alignment of the type cannot be trusted. + return 0; } return MinAlign(Align, GVOffset); } |