[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h
Chris Lattner
sabre at nondot.org
Thu Mar 29 11:58:25 PDT 2007
Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.243 -> 1.244
Reader.h updated: 1.50 -> 1.51
---
Log message:
the bytecode reader supports dematerializeFunction
---
Diffs of the changes: (+22 -7)
Reader.cpp | 3 ---
Reader.h | 26 ++++++++++++++++++++++----
2 files changed, 22 insertions(+), 7 deletions(-)
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.243 llvm/lib/Bytecode/Reader/Reader.cpp:1.244
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.243 Thu Mar 1 14:25:31 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Thu Mar 29 13:58:08 2007
@@ -1636,8 +1636,6 @@
BlockEnd = Fi->second.EndBuf;
assert(Fi->first == Func && "Found wrong function?");
- LazyFunctionLoadMap.erase(Fi);
-
this->ParseFunctionBody(Func);
return false;
}
@@ -1668,7 +1666,6 @@
ParseFunctionBody(Func);
++Fi;
}
- LazyFunctionLoadMap.clear();
return false;
}
Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.50 llvm/lib/Bytecode/Reader/Reader.h:1.51
--- llvm/lib/Bytecode/Reader/Reader.h:1.50 Tue Feb 13 01:28:20 2007
+++ llvm/lib/Bytecode/Reader/Reader.h Thu Mar 29 13:58:08 2007
@@ -154,20 +154,38 @@
bool ParseAllFunctionBodies(std::string* ErrMsg);
/// @brief Parse the next function of specific type
- bool ParseFunction(Function* Func, std::string* ErrMsg) ;
+ bool ParseFunction(Function* Func, std::string* ErrMsg);
/// This method is abstract in the parent ModuleProvider class. Its
/// implementation is identical to the ParseFunction method.
/// @see ParseFunction
/// @brief Make a specific function materialize.
virtual bool materializeFunction(Function *F, std::string *ErrMsg = 0) {
- LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F);
- if (Fi == LazyFunctionLoadMap.end())
- return false;
+ // If it already is material, ignore the request.
+ if (!F->hasNotBeenReadFromBytecode()) return false;
+
+ assert(LazyFunctionLoadMap.count(F) &&
+ "not materialized but I don't know about it?");
if (ParseFunction(F,ErrMsg))
return true;
return false;
}
+
+ /// dematerializeFunction - If the given function is read in, and if the
+ /// module provider supports it, release the memory for the function, and set
+ /// it up to be materialized lazily. If the provider doesn't support this
+ /// capability, this method is a noop.
+ ///
+ virtual void dematerializeFunction(Function *F) {
+ // If the function is not materialized, or if it is a prototype, ignore.
+ if (F->hasNotBeenReadFromBytecode() ||
+ F->isDeclaration())
+ return;
+
+ // Just forget the function body, we can remat it later.
+ F->deleteBody();
+ F->setLinkage(GlobalValue::GhostLinkage);
+ }
/// This method is abstract in the parent ModuleProvider class. Its
/// implementation is identical to ParseAllFunctionBodies.
More information about the llvm-commits
mailing list