aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-03-29 18:58:08 +0000
committerChris Lattner <sabre@nondot.org>2007-03-29 18:58:08 +0000
commitf735f7b3ac424bd701af2da2e3d4b69fbcb2b203 (patch)
tree9ea0e37e7fde3639627a01ed022d85b1e31d852f /lib
parentcb2df95c88f6bb819e8a3d9f9598c687cdf334a1 (diff)
downloadexternal_llvm-f735f7b3ac424bd701af2da2e3d4b69fbcb2b203.zip
external_llvm-f735f7b3ac424bd701af2da2e3d4b69fbcb2b203.tar.gz
external_llvm-f735f7b3ac424bd701af2da2e3d4b69fbcb2b203.tar.bz2
the bytecode reader supports dematerializeFunction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp3
-rw-r--r--lib/Bytecode/Reader/Reader.h26
2 files changed, 22 insertions, 7 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index cb798df..f0f6597 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -1636,8 +1636,6 @@ bool BytecodeReader::ParseFunction(Function* Func, std::string* ErrMsg) {
BlockEnd = Fi->second.EndBuf;
assert(Fi->first == Func && "Found wrong function?");
- LazyFunctionLoadMap.erase(Fi);
-
this->ParseFunctionBody(Func);
return false;
}
@@ -1668,7 +1666,6 @@ bool BytecodeReader::ParseAllFunctionBodies(std::string* ErrMsg) {
ParseFunctionBody(Func);
++Fi;
}
- LazyFunctionLoadMap.clear();
return false;
}
diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h
index a8e879c..8da286b 100644
--- a/lib/Bytecode/Reader/Reader.h
+++ b/lib/Bytecode/Reader/Reader.h
@@ -154,20 +154,38 @@ public:
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.