/// (e.g.) blockaddress forward references.
bool WillMaterializeAllForwardRefs = false;
- /// Functions that have block addresses taken. This is usually empty.
- SmallPtrSet<const Function *, 4> BlockAddressesTaken;
-
/// True if any Metadata block has been materialized.
bool IsMetadataMaterialized = false;
void releaseBuffer();
- bool isDematerializable(const GlobalValue *GV) const override;
std::error_code materialize(GlobalValue *GV) override;
std::error_code materializeModule(Module *M) override;
std::vector<StructType *> getIdentifiedStructTypes() const override;
- void dematerialize(GlobalValue *GV) override;
/// \brief Main interface to parsing a bitcode buffer.
/// \returns true if an error occurred.
if (!Fn)
return error("Invalid record");
- // Don't let Fn get dematerialized.
- BlockAddressesTaken.insert(Fn);
-
// If the function is already parsed we can insert the block address right
// away.
BasicBlock *BB;
return materializeForwardReferencedFunctions();
}
-bool BitcodeReader::isDematerializable(const GlobalValue *GV) const {
- const Function *F = dyn_cast<Function>(GV);
- if (!F || F->isDeclaration())
- return false;
-
- // Dematerializing F would leave dangling references that wouldn't be
- // reconnected on re-materialization.
- if (BlockAddressesTaken.count(F))
- return false;
-
- return DeferredFunctionInfo.count(const_cast<Function*>(F));
-}
-
-void BitcodeReader::dematerialize(GlobalValue *GV) {
- Function *F = dyn_cast<Function>(GV);
- // If this function isn't dematerializable, this is a noop.
- if (!F || !isDematerializable(F))
- return;
-
- assert(DeferredFunctionInfo.count(F) && "No info to read function later?");
-
- // Just forget the function body, we can remat it later.
- F->dropAllReferences();
- F->setIsMaterializable(true);
-}
-
std::error_code BitcodeReader::materializeModule(Module *M) {
assert(M == TheModule &&
"Can only Materialize the Module this BitcodeReader is attached to.");