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
This commit is contained in:
Manman Ren
2013-10-22 01:40:25 +00:00
parent 8348b7d400
commit 11d78777d5
2 changed files with 56 additions and 1 deletions

View File

@@ -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();