diff options
| author | Juergen Ributzka <juergen@apple.com> | 2014-02-13 04:19:26 +0000 |
|---|---|---|
| committer | Juergen Ributzka <juergen@apple.com> | 2014-02-13 04:19:26 +0000 |
| commit | 2b97f9b21108b3bff00f5d3c60cb6eeb97747e24 (patch) | |
| tree | 661d8d658c78fb75bb96f0045d4d822188daae1c /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
| parent | ea2519c37b79eed0519582a00293d29ecff9441c (diff) | |
| download | bcm5719-llvm-2b97f9b21108b3bff00f5d3c60cb6eeb97747e24.tar.gz bcm5719-llvm-2b97f9b21108b3bff00f5d3c60cb6eeb97747e24.zip | |
[DAG] Fix the recognition of opaque constants in the SelectionDAGBuilder.
This fix checks the original LLVM IR node to identify opaque constants by
looking for the bitcast-constant pattern. Originally we looked at the generated
SDNode, but this might lead to incorrect results. The SDNode could have been
generated by an constant expression that was folded to a constant.
This fixes <rdar://problem/16050719>
llvm-svn: 201291
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 3d51e9ede95..a7c99849058 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2996,9 +2996,13 @@ void SelectionDAGBuilder::visitBitCast(const User &I) { if (DestVT != N.getValueType()) setValue(&I, DAG.getNode(ISD::BITCAST, getCurSDLoc(), DestVT, N)); // convert types. - else if(ConstantSDNode *C = dyn_cast<ConstantSDNode>(N)) - setValue(&I, DAG.getConstant(C->getAPIntValue(), C->getValueType(0), - /*isTarget=*/false, /*isOpaque*/true)); + // Check if the original LLVM IR Operand was a ConstantInt, because getValue() + // might fold any kind of constant expression to an integer constant and that + // is not what we are looking for. Only regcognize a bitcast of a genuine + // constant integer as an opaque constant. + else if(ConstantInt *C = dyn_cast<ConstantInt>(I.getOperand(0))) + setValue(&I, DAG.getConstant(C->getValue(), DestVT, /*isTarget=*/false, + /*isOpaque*/true)); else setValue(&I, N); // noop cast. } |

