diff options
| author | James Molloy <james.molloy@arm.com> | 2016-10-17 12:54:07 +0000 |
|---|---|---|
| committer | James Molloy <james.molloy@arm.com> | 2016-10-17 12:54:07 +0000 |
| commit | aa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef (patch) | |
| tree | 4051488e7e83fe93dbfda20e32f9934488606484 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
| parent | ecbcd7ca11005fbb8a314d92b7abc79750a78274 (diff) | |
| download | bcm5719-llvm-aa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef.tar.gz bcm5719-llvm-aa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef.zip | |
[SDAG] Use ABI type alignment for constant pools when optimizing for size
SelectionDAG::getConstantPool will automatically determine an appropriate alignment if one is not specified. It does this by querying the type's preferred alignment. This can end up creating quite a lot of padding when the preferred alignment for vectors is 128.
In optimize-for-size mode, it makes sense to instead query the ABI type alignment which is often smaller and causes less padding.
llvm-svn: 284381
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 19fae7fa748..7cca214da49 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1315,7 +1315,9 @@ SDValue SelectionDAG::getConstantPool(const Constant *C, EVT VT, assert((TargetFlags == 0 || isTarget) && "Cannot set target flags on target-independent globals"); if (Alignment == 0) - Alignment = getDataLayout().getPrefTypeAlignment(C->getType()); + Alignment = MF->getFunction()->optForSize() + ? getDataLayout().getABITypeAlignment(C->getType()) + : getDataLayout().getPrefTypeAlignment(C->getType()); unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool; FoldingSetNodeID ID; AddNodeIDNode(ID, Opc, getVTList(VT), None); |

