diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index d9866c87ee4..71f1dd0d6b3 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -239,15 +239,18 @@ void *JIT::getPointerToFunction(Function *F) { return Addr; // Check if function already code gen'd // Make sure we read in the function if it exists in this Module - try { - MP->materializeFunction(F); - } catch ( std::string& errmsg ) { - std::cerr << "Error reading bytecode file: " << errmsg << "\n"; - abort(); - } catch (...) { - std::cerr << "Error reading bytecode file!\n"; - abort(); - } + if (F->hasNotBeenReadFromBytecode()) + try { + MP->materializeFunction(F); + } catch ( std::string& errmsg ) { + std::cerr << "Error reading function '" << F->getName() + << "' from bytecode file: " << errmsg << "\n"; + abort(); + } catch (...) { + std::cerr << "Error reading function '" << F->getName() + << "from bytecode file!\n"; + abort(); + } if (F->isExternal()) { void *Addr = getPointerToNamedFunction(F->getName());