diff options
author | Michael Liao <michael.hliao@gmail.com> | 2019-05-10 14:57:42 +0000 |
---|---|---|
committer | Michael Liao <michael.hliao@gmail.com> | 2019-05-10 14:57:42 +0000 |
commit | b284414a1bf1be379cd28c8a10075f0d5238d18d (patch) | |
tree | c59866b197761748b3c4eb83a449c4b1d4b6f2fb /llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp | |
parent | 37dc0ced7a104852d433f0e6012dc800d52e2438 (diff) | |
download | bcm5719-llvm-b284414a1bf1be379cd28c8a10075f0d5238d18d.tar.gz bcm5719-llvm-b284414a1bf1be379cd28c8a10075f0d5238d18d.zip |
[InferAddressSpaces] Enhance the handling of cosntexpr.
Summary:
- Constant expressions may not be added in strict postorder as the
forward instruction scan order. Thus, for a constant express (CE0), if
its operand (CE1) is used in an previous instruction, they are not in
postorder. However, different from
`cloneInstructionWithNewAddressSpace`,
`cloneConstantExprWithNewAddressSpace` doesn't bookkeep uninferred
instructions for later resolving. That results in failure of inferring
constant address.
- This patch adds the support to infer constant expression operand
recursively, since there won't be loop, if that operand is another
constant expression.
Reviewers: arsenm
Subscribers: jholewinski, jvesely, wdng, nhaehnle, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61760
llvm-svn: 360431
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp index a59248cc8c5..36115e96cf4 100644 --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -553,10 +553,17 @@ static Value *cloneConstantExprWithNewAddressSpace( if (Value *NewOperand = ValueWithNewAddrSpace.lookup(Operand)) { IsNew = true; NewOperands.push_back(cast<Constant>(NewOperand)); - } else { - // Otherwise, reuses the old operand. - NewOperands.push_back(Operand); + continue; } + if (auto CExpr = dyn_cast<ConstantExpr>(Operand)) + if (Value *NewOperand = cloneConstantExprWithNewAddressSpace( + CExpr, NewAddrSpace, ValueWithNewAddrSpace)) { + IsNew = true; + NewOperands.push_back(cast<Constant>(NewOperand)); + continue; + } + // Otherwise, reuses the old operand. + NewOperands.push_back(Operand); } // If !IsNew, we will replace the Value with itself. However, replaced values |