diff options
author | Chris Lattner <sabre@nondot.org> | 2003-04-24 18:25:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-04-24 18:25:27 +0000 |
commit | 16125fb74966ebe416c669e28e453be68eda32a7 (patch) | |
tree | 38793555d17f73faab7ea8d3e147e3b2974b7c34 /lib/Transforms/TransformInternals.cpp | |
parent | ad80a46caacef8b4073df3fc10e0c58ebbee4ec7 (diff) |
Make the levelraise pass be well behaved w.r.t the TargetData that the current
PassMAnager provides.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/TransformInternals.cpp')
-rw-r--r-- | lib/Transforms/TransformInternals.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 62953f8c6d..d3641e6f0d 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -11,15 +11,9 @@ #include "llvm/Function.h" #include "llvm/iOther.h" -// TargetData Hack: Eventually we will have annotations given to us by the -// backend so that we know stuff about type size and alignments. For now -// though, just use this, because it happens to match the model that GCC uses. -// -const TargetData TD("LevelRaise: Should be GCC though!"); - - static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset, - std::vector<Value*> &Indices) { + std::vector<Value*> &Indices, + const TargetData &TD) { assert(Offset < TD.getTypeSize(STy) && "Offset not in composite!"); const StructLayout *SL = TD.getStructLayout(STy); @@ -52,7 +46,7 @@ static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset, // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, std::vector<Value*> &Indices, - bool StopEarly) { + const TargetData &TD, bool StopEarly) { if (Offset == 0 && StopEarly && !Indices.empty()) return Ty; // Return the leaf type @@ -60,7 +54,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, const Type *NextType; if (const StructType *STy = dyn_cast<StructType>(Ty)) { ThisOffset = Offset; - NextType = getStructOffsetStep(STy, ThisOffset, Indices); + NextType = getStructOffsetStep(STy, ThisOffset, Indices, TD); } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { assert(Offset < TD.getTypeSize(ATy) && "Offset not in composite!"); @@ -75,7 +69,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, unsigned SubOffs = Offset - ThisOffset; const Type *LeafTy = getStructOffsetType(NextType, SubOffs, - Indices, StopEarly); + Indices, TD, StopEarly); Offset = ThisOffset + SubOffs; return LeafTy; } @@ -87,6 +81,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, // const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, std::vector<Value*> &Indices, + const TargetData &TD, BasicBlock::iterator *BI) { const CompositeType *CompTy = dyn_cast<CompositeType>(Ty); if (CompTy == 0) return 0; @@ -116,7 +111,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, if (const StructType *StructTy = dyn_cast<StructType>(CompTy)) { // Step into the appropriate element of the structure... uint64_t ActualOffset = (Offset < 0) ? 0 : (uint64_t)Offset; - NextTy = getStructOffsetStep(StructTy, ActualOffset, Indices); + NextTy = getStructOffsetStep(StructTy, ActualOffset, Indices, TD); Offset -= ActualOffset; } else { const Type *ElTy = cast<SequentialType>(CompTy)->getElementType(); |