summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-25 20:19:55 +0000
committerChris Lattner <sabre@nondot.org>2003-11-25 20:19:55 +0000
commit567444309a462ca8e198635dc43d20b7560910d2 (patch)
treec95e98c6349b72c9325e79a9f579d79ac10b3743 /llvm/lib/Analysis/DataStructure/Local.cpp
parentbe157c0303509bbd5274f893cdaffccf05409c60 (diff)
downloadbcm5719-llvm-567444309a462ca8e198635dc43d20b7560910d2.tar.gz
bcm5719-llvm-567444309a462ca8e198635dc43d20b7560910d2.zip
Do not depend on index type to determine whether it is a structure or sequential index
llvm-svn: 10221
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/Local.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp
index a7cf854c47e..5cafefaff44 100644
--- a/llvm/lib/Analysis/DataStructure/Local.cpp
+++ b/llvm/lib/Analysis/DataStructure/Local.cpp
@@ -17,6 +17,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
#include "Support/CommandLine.h"
@@ -366,12 +367,17 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) {
// All of these subscripts are indexing INTO the elements we have...
unsigned Offset = 0;
- for (unsigned i = 2, e = GEP.getNumOperands(); i < e; ++i)
- if (GEP.getOperand(i)->getType() == Type::LongTy) {
- // Get the type indexing into...
- const SequentialType *STy = cast<SequentialType>(CurTy);
- CurTy = STy->getElementType();
+ for (gep_type_iterator I = gep_type_begin(GEP), E = gep_type_end(GEP);
+ I != E; ++I)
+ if (const StructType *STy = dyn_cast<StructType>(*I)) {
+ unsigned FieldNo = cast<ConstantUInt>(I.getOperand())->getValue();
+ Offset += TD.getStructLayout(STy)->MemberOffsets[FieldNo];
+ }
+
+
#if 0
+ if (const SequentialType *STy = cast<SequentialType>(*I)) {
+ CurTy = STy->getElementType();
if (ConstantSInt *CS = dyn_cast<ConstantSInt>(GEP.getOperand(i))) {
Offset += CS->getValue()*TD.getTypeSize(CurTy);
} else {
@@ -394,13 +400,8 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) {
N->mergeIndexes(RawOffset+j, RawOffset+i*ElSize+j);
}
}
-#endif
- } else if (GEP.getOperand(i)->getType() == Type::UByteTy) {
- unsigned FieldNo = cast<ConstantUInt>(GEP.getOperand(i))->getValue();
- const StructType *STy = cast<StructType>(CurTy);
- Offset += TD.getStructLayout(STy)->MemberOffsets[FieldNo];
- CurTy = STy->getContainedType(FieldNo);
}
+#endif
// Add in the offset calculated...
Value.setOffset(Value.getOffset()+Offset);
OpenPOWER on IntegriCloud