diff options
author | Manman Ren <manman.ren@gmail.com> | 2013-10-22 01:40:25 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2013-10-22 01:40:25 +0000 |
commit | 11d78777d5ced531823abc0fd111e1c4594dc53e (patch) | |
tree | 2daebf800e47acb19979d1061973a9758594ed40 /lib/Analysis | |
parent | 8348b7d4003e4c404ef3f054001de499f24676c9 (diff) | |
download | external_llvm-11d78777d5ced531823abc0fd111e1c4594dc53e.zip external_llvm-11d78777d5ced531823abc0fd111e1c4594dc53e.tar.gz external_llvm-11d78777d5ced531823abc0fd111e1c4594dc53e.tar.bz2 |
TBAA: fix PR17620.
We can have a struct type with a single field and the field does not start
with 0. In that case, we should correctly update the offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/TypeBasedAliasAnalysis.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Analysis/TypeBasedAliasAnalysis.cpp b/lib/Analysis/TypeBasedAliasAnalysis.cpp index 9026dc9..6791d4b 100644 --- a/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -231,8 +231,12 @@ namespace { if (Node->getNumOperands() < 2) return TBAAStructTypeNode(); - // Special handling for a scalar type node. + // Fast path for a scalar type node and a struct type node with a single + // field. if (Node->getNumOperands() <= 3) { + uint64_t Cur = Node->getNumOperands() == 2 ? 0 : + cast<ConstantInt>(Node->getOperand(2))->getZExtValue(); + Offset -= Cur; MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(1)); if (!P) return TBAAStructTypeNode(); |