aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/ReaderInternals.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-08 22:52:54 +0000
committerChris Lattner <sabre@nondot.org>2003-10-08 22:52:54 +0000
commit4ee8ef2a5d5a28cf5255b986d57dc658fa060479 (patch)
treed08ab107eb58849ab3ed824df815aab381e4aa00 /lib/Bytecode/Reader/ReaderInternals.h
parent6e44802ec03647549c19a7d0313fae009fac7a49 (diff)
This patch substantially simplifies and cleans up handling of basic blocks
in the bytecode parser. Before we tried to shoehorn basic blocks into the "getValue" code path with other types of values. For a variety of reasons this was a bad idea, so this patch separates it out into its own data structure. This simplifies the code, makes it fit in 80 columns, and is also much faster. In a testcase provided by Bill, which has lots of PHI nodes, this patch speeds up bytecode parsing from taking 6.9s to taking 2.32s. More speedups to follow later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/ReaderInternals.h')
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h28
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 8825df7fbe..b0c7abfff6 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -103,6 +103,8 @@ private:
ValueTable Values, LateResolveValues;
ValueTable ModuleValues;
+ std::vector<BasicBlock*> ParsedBasicBlocks;
+
// GlobalRefs - This maintains a mapping between <Type, Slot #>'s and forward
// references to global values or constants. Such values may be referenced
// before they are defined, and if so, the temporary object that they
@@ -153,15 +155,16 @@ private:
void ParseVersionInfo (const unsigned char *&Buf, const unsigned char *End);
void ParseModuleGlobalInfo(const unsigned char *&Buf, const unsigned char *E);
void ParseSymbolTable(const unsigned char *&Buf, const unsigned char *End,
- SymbolTable *);
+ SymbolTable *, Function *CurrentFunction);
void ParseFunction(const unsigned char *&Buf, const unsigned char *End);
void ParseGlobalTypes(const unsigned char *&Buf, const unsigned char *EndBuf);
- std::auto_ptr<BasicBlock>
- ParseBasicBlock(const unsigned char *&Buf, const unsigned char *End);
+ BasicBlock *ParseBasicBlock(const unsigned char *&Buf,
+ const unsigned char *End,
+ unsigned BlockNo);
- bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End,
- Instruction *&);
+ bool ParseInstruction(const unsigned char *&Buf, const unsigned char *End,
+ Instruction *&);
std::auto_ptr<RawInst> ParseRawInst(const unsigned char *&Buf,
const unsigned char *End);
@@ -179,6 +182,7 @@ private:
Value *getValue(const Type *Ty, unsigned num, bool Create = true);
Value *getValue(unsigned TypeID, unsigned num, bool Create = true);
const Type *getType(unsigned ID);
+ BasicBlock *getBasicBlock(unsigned ID);
Constant *getConstantValue(const Type *Ty, unsigned num);
int insertValue(Value *V, ValueTable &Table); // -1 = Failure
@@ -207,12 +211,6 @@ struct InstPlaceHolderHelper : public Instruction {
virtual Instruction *clone() const { abort(); return 0; }
};
-struct BBPlaceHolderHelper : public BasicBlock {
- BBPlaceHolderHelper(const Type *Ty) : BasicBlock() {
- assert(Ty == Type::LabelTy);
- }
-};
-
struct ConstantPlaceHolderHelper : public Constant {
ConstantPlaceHolderHelper(const Type *Ty)
: Constant(Ty) {}
@@ -220,7 +218,6 @@ struct ConstantPlaceHolderHelper : public Constant {
};
typedef PlaceholderDef<InstPlaceHolderHelper> ValPHolder;
-typedef PlaceholderDef<BBPlaceHolderHelper> BBPHolder;
typedef PlaceholderDef<ConstantPlaceHolderHelper> ConstPHolder;
// Some common errors we find
@@ -232,12 +229,7 @@ static const std::string Error_DestSlot = "No destination slot found.";
static inline unsigned getValueIDNumberFromPlaceHolder(Value *Val) {
if (isa<Constant>(Val))
return ((ConstPHolder*)Val)->getID();
-
- // else discriminate by type
- switch (Val->getType()->getPrimitiveID()) {
- case Type::LabelTyID: return ((BBPHolder*)Val)->getID();
- default: return ((ValPHolder*)Val)->getID();
- }
+ return ((ValPHolder*)Val)->getID();
}
static inline void readBlock(const unsigned char *&Buf,