diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index b86d6e0..47957b4 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -27,6 +27,12 @@
 #include "llvm/OperandTraits.h"
 using namespace llvm;
 
+void BitcodeReader::getForwardReferencedFunctions(std::vector<Function*> &Fwd) {
+  for (BlockAddrRefMapTy::iterator I = BlockAddrFwdRefs.begin(),
+         E = BlockAddrFwdRefs.end(); I != E; ++I)
+    Fwd.push_back(I->first);
+}
+
 void BitcodeReader::FreeState() {
   if (BufferOwned)
     delete Buffer;
@@ -2779,6 +2785,15 @@ Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer,
   }
   // Have the BitcodeReader dtor delete 'Buffer'.
   R->setBufferOwned(true);
+
+  std::vector<Function*> Fwd;
+  R->getForwardReferencedFunctions(Fwd);
+  for (std::vector<Function*>::iterator I = Fwd.begin(), E = Fwd.end();
+       I != E; ++I) {
+    Function *F = *I;
+    F->Materialize();
+  }
+
   return M;
 }
 
diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h
index 978b15b..86ae53c 100644
--- a/lib/Bitcode/Reader/BitcodeReader.h
+++ b/lib/Bitcode/Reader/BitcodeReader.h
@@ -173,7 +173,8 @@ class BitcodeReader : public GVMaterializer {
   /// BlockAddrFwdRefs - These are blockaddr references to basic blocks.  These
   /// are resolved lazily when functions are loaded.
   typedef std::pair<unsigned, GlobalVariable*> BlockAddrRefTy;
-  DenseMap<Function*, std::vector<BlockAddrRefTy> > BlockAddrFwdRefs;
+  typedef DenseMap<Function*, std::vector<BlockAddrRefTy> > BlockAddrRefMapTy;
+  BlockAddrRefMapTy BlockAddrFwdRefs;
 
 public:
   explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
@@ -184,7 +185,9 @@ public:
   ~BitcodeReader() {
     FreeState();
   }
-  
+
+  void getForwardReferencedFunctions(std::vector<Function*> &Fwd);
+
   void FreeState();
   
   /// setBufferOwned - If this is true, the reader will destroy the MemoryBuffer
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index 2eff164..180b5b1 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -112,6 +112,7 @@ set(VMCoreSources
   VMCore/PassManagerTest.cpp
   VMCore/ValueMapTest.cpp
   VMCore/VerifierTest.cpp
+  VMCore/LazyTest.cpp
   )
 
 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
diff --git a/unittests/VMCore/LazyTest.cpp b/unittests/VMCore/LazyTest.cpp
new file mode 100644
index 0000000..f6a2e1c
--- /dev/null
+++ b/unittests/VMCore/LazyTest.cpp
@@ -0,0 +1,57 @@
+#include "llvm/Analysis/Verifier.h"
+#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
+#include "llvm/LLVMContext.h"
+#include "llvm/Module.h"
+#include "llvm/PassManager.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+// This is a test for PR11677.
+
+namespace llvm {
+namespace {
+
+static Module *makeLLVMModule() {
+  Module* Mod = new Module("test-mem", getGlobalContext());
+
+  FunctionType* FuncTy =
+    FunctionType::get(Type::getVoidTy(Mod->getContext()), false);
+  Function* Func = Function::Create(FuncTy,GlobalValue::ExternalLinkage,
+                                    "func", Mod);
+
+  BasicBlock* Entry = BasicBlock::Create(Mod->getContext(), "entry", Func);
+  new UnreachableInst(Mod->getContext(), Entry);
+
+  BasicBlock* BB = BasicBlock::Create(Mod->getContext(), "bb", Func);
+  new UnreachableInst(Mod->getContext(), BB);
+
+  PointerType* Int8Ptr = Type::getInt8PtrTy(Mod->getContext());
+  new GlobalVariable(*Mod, Int8Ptr, /*isConstant=*/true,
+                     GlobalValue::ExternalLinkage,
+                     BlockAddress::get(BB), "table");
+
+  return Mod;
+}
+
+static void writeModuleToBuffer(std::vector<unsigned char> &Buffer) {
+  Module *Mod = makeLLVMModule();
+  BitstreamWriter Stream(Buffer);
+  WriteBitcodeToStream(Mod, Stream);
+}
+
+TEST(LasyTest, BlockAddr) {
+  std::vector<unsigned char> Mem;
+  writeModuleToBuffer(Mem);
+  StringRef Data((const char*)&Mem[0], Mem.size());
+  MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Data);
+  std::string errMsg;
+  Module *m = getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg);
+  PassManager passes;
+  passes.add(createVerifierPass());
+  passes.run(*m);
+}
+}
+}
