[llvm-commits] CVS: llvm-java/lib/Compiler/OperandStack.cpp Locals.h Locals.cpp Compiler.cpp BasicBlockBuilder.h
Alkis Evlogimenos
alkis at cs.uiuc.edu
Thu Feb 3 14:37:43 PST 2005
Changes in directory llvm-java/lib/Compiler:
OperandStack.cpp updated: 1.11 -> 1.12
Locals.h updated: 1.4 -> 1.5
Locals.cpp updated: 1.9 -> 1.10
Compiler.cpp updated: 1.213 -> 1.214
BasicBlockBuilder.h updated: 1.3 -> 1.4
---
Log message:
Simplify code by adding the branch from the entry block to the first
bytecode block after compilation of a function is done.
---
Diffs of the changes: (+9 -39)
BasicBlockBuilder.h | 3 ---
Compiler.cpp | 5 ++++-
Locals.cpp | 29 +++--------------------------
Locals.h | 5 -----
OperandStack.cpp | 6 ++----
5 files changed, 9 insertions(+), 39 deletions(-)
Index: llvm-java/lib/Compiler/OperandStack.cpp
diff -u llvm-java/lib/Compiler/OperandStack.cpp:1.11 llvm-java/lib/Compiler/OperandStack.cpp:1.12
--- llvm-java/lib/Compiler/OperandStack.cpp:1.11 Thu Feb 3 15:35:58 2005
+++ llvm-java/lib/Compiler/OperandStack.cpp Thu Feb 3 16:37:32 2005
@@ -47,10 +47,8 @@
if (it == slotMap.end()) {
// Insert the alloca at the beginning of the entry block.
- BasicBlock& entry = bb->getParent()->getEntryBlock();
- assert(entry.getTerminator() && "Entry block must have a terminator!");
- AllocaInst* alloca =
- new AllocaInst(type, NULL, "opStack", entry.getTerminator());
+ BasicBlock* entry = &bb->getParent()->getEntryBlock();
+ AllocaInst* alloca = new AllocaInst(type, NULL, "opStack", entry);
it = slotMap.insert(it, std::make_pair(type, alloca));
}
Index: llvm-java/lib/Compiler/Locals.h
diff -u llvm-java/lib/Compiler/Locals.h:1.4 llvm-java/lib/Compiler/Locals.h:1.5
--- llvm-java/lib/Compiler/Locals.h:1.4 Thu Feb 3 15:35:58 2005
+++ llvm-java/lib/Compiler/Locals.h Thu Feb 3 16:37:32 2005
@@ -43,11 +43,6 @@
/// insertAtEnd BasicBlock
void store(unsigned i, Value* value, BasicBlock* insertAtEnd);
- /// @brief - Stores the value \c value on the \c i'th local
- /// variable and prepends any instructions to implement this before \c
- /// insertBefore Instruction
- void store(unsigned i, Value* value, Instruction* insertBefore);
-
/// @brief - Loads the value of the \c i'th local variable of type
/// \c type and appends any instructions to implement this to \c
/// insertAtEnd BasicBlock
Index: llvm-java/lib/Compiler/Locals.cpp
diff -u llvm-java/lib/Compiler/Locals.cpp:1.9 llvm-java/lib/Compiler/Locals.cpp:1.10
--- llvm-java/lib/Compiler/Locals.cpp:1.9 Thu Feb 3 15:35:58 2005
+++ llvm-java/lib/Compiler/Locals.cpp Thu Feb 3 16:37:32 2005
@@ -41,39 +41,16 @@
SlotMap::iterator it = slotMap.find(storageTy);
if (it == slotMap.end()) {
- // Insert the alloca at the beginning of the entry block.
- BasicBlock& entry = insertAtEnd->getParent()->getEntryBlock();
- assert(entry.getTerminator() && "Entry block must have a terminator!");
+ // Insert the alloca at the end of the entry block.
+ BasicBlock* entry = &insertAtEnd->getParent()->getEntryBlock();
AllocaInst* alloca =
- new AllocaInst(storageTy, NULL, "local"+utostr(i), entry.getTerminator());
+ new AllocaInst(storageTy, NULL, "local"+utostr(i), entry);
it = slotMap.insert(it, std::make_pair(storageTy, alloca));
}
new StoreInst(value, it->second, insertAtEnd);
}
-void Locals::store(unsigned i, Value* value, Instruction* insertBefore)
-{
- const Type* valueTy = value->getType();
- const Type* storageTy = getStorageType(valueTy);
- if (valueTy != storageTy)
- value = new CastInst(value, storageTy, "to-storage-type", insertBefore);
-
- SlotMap& slotMap = TheLocals[i];
- SlotMap::iterator it = slotMap.find(storageTy);
-
- if (it == slotMap.end()) {
- // Insert the alloca at the beginning of the entry block.
- BasicBlock& entry = insertBefore->getParent()->getParent()->getEntryBlock();
- assert(entry.getTerminator() && "Entry block must have a terminator!");
- AllocaInst* alloca =
- new AllocaInst(storageTy, NULL, "local"+utostr(i), entry.getTerminator());
- it = slotMap.insert(it, std::make_pair(storageTy, alloca));
- }
-
- new StoreInst(value, it->second, insertBefore);
-}
-
llvm::Value* Locals::load(unsigned i, const Type* valueTy,
BasicBlock* insertAtEnd)
{
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.213 llvm-java/lib/Compiler/Compiler.cpp:1.214
--- llvm-java/lib/Compiler/Compiler.cpp:1.213 Thu Feb 3 15:35:58 2005
+++ llvm-java/lib/Compiler/Compiler.cpp Thu Feb 3 16:37:32 2005
@@ -1365,7 +1365,7 @@
unsigned index = 0;
for (Function::aiterator
a = function->abegin(), ae = function->aend(); a != ae; ++a) {
- locals_.store(index, a, function->getEntryBlock().getTerminator());
+ locals_.store(index, a, &function->getEntryBlock());
index += isTwoSlotType(a->getType()) ? 2 : 1;
}
@@ -1427,6 +1427,9 @@
}
}
+ // Add an unconditional branch from the entry block to bb0.
+ new BranchInst(bb0, &function->getEntryBlock());
+
// FIXME: remove empty basic blocks (we have empty basic blocks
// because of our lack of exception support).
for (Function::iterator bb = function->begin(), be = function->end();
Index: llvm-java/lib/Compiler/BasicBlockBuilder.h
diff -u llvm-java/lib/Compiler/BasicBlockBuilder.h:1.3 llvm-java/lib/Compiler/BasicBlockBuilder.h:1.4
--- llvm-java/lib/Compiler/BasicBlockBuilder.h:1.3 Thu Feb 3 15:35:58 2005
+++ llvm-java/lib/Compiler/BasicBlockBuilder.h Thu Feb 3 16:37:32 2005
@@ -51,9 +51,6 @@
// Create the block for bytecode 0 (bb0).
BasicBlock* bb = getOrCreateBasicBlockAt(0);
- // Add an unconditional branch from the entry block to bb0.
- new BranchInst(bb, entry);
-
// Create basic blocks for exception handlers.
const CodeAttribute::Exceptions& exceptions = c->getExceptions();
for (unsigned i = 0, e = exceptions.size(); i != e; ++i)
More information about the llvm-commits
mailing list