From cba8c5fe317bcad85d0bebb7aa68e52353f54916 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 6 Aug 2015 23:57:04 +0000 Subject: MIR Serialization: Fix serialization of unnamed IR block references. The block address machine operands can reference IR blocks in other functions. This commit fixes a bug where the references to unnamed IR blocks in other functions weren't serialized correctly. llvm-svn: 244299 --- llvm/lib/CodeGen/MIRPrinter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp') diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index cc131bc4641..e162a8f73e2 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -476,7 +476,16 @@ void MIPrinter::printIRBlockReference(const BasicBlock &BB) { printLLVMNameWithoutPrefix(OS, BB.getName()); return; } - int Slot = MST.getLocalSlot(&BB); + const Function *F = BB.getParent(); + int Slot; + if (F == MST.getCurrentFunction()) { + Slot = MST.getLocalSlot(&BB); + } else { + ModuleSlotTracker CustomMST(F->getParent(), + /*ShouldInitializeAllMetadata=*/false); + CustomMST.incorporateFunction(*F); + Slot = CustomMST.getLocalSlot(&BB); + } if (Slot == -1) OS << ""; else -- cgit v1.2.3