summaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-04-13 19:31:49 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-04-13 19:31:49 +0000
commit99c1942ba711c8e5e4e5b1789081a4f8cb4368c0 (patch)
treed9d8c5a2452e3d3402a4515b98391be8174a8c65 /lib/Analysis/DataStructure
parent60d07eeffe80e8b7a3e1fad9420614b8438ba7e3 (diff)
Handle some kernel code than ends in [0 x sbyte]. I think this is safe
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r--lib/Analysis/DataStructure/Local.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index 72eee24964e..f191bb3159b 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -1116,8 +1116,17 @@ void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) {
const StructLayout *SL = TD.getStructLayout(CS->getType());
for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) {
DSNode *NHN = NH.getNode();
- DSNodeHandle NewNH(NHN, NH.getOffset()+(unsigned)SL->MemberOffsets[i]);
- MergeConstantInitIntoNode(NewNH, cast<Constant>(CS->getOperand(i)));
+ //Some programmers think ending a structure with a [0 x sbyte] is cute
+ //This should be ok as the allocation type should grow this type when
+ //it is merged in if it is bigger.
+ if (SL->MemberOffsets[i] < SL->StructSize) {
+ DSNodeHandle NewNH(NHN, NH.getOffset()+(unsigned)SL->MemberOffsets[i]);
+ MergeConstantInitIntoNode(NewNH, cast<Constant>(CS->getOperand(i)));
+ } else if (SL->MemberOffsets[i] == SL->StructSize) {
+ DEBUG(std::cerr << "Zero size element at end of struct\n");
+ } else {
+ assert(0 && "type was smaller than offsets of of struct layout indicate");
+ }
}
} else if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) {
// Noop