fix AsmPrinter::GetBlockAddressSymbol to always return a unique
[oota-llvm.git] / lib / CodeGen / MachineModuleInfo.cpp
index fdbda8f715fa6f1b6f2aef14c2fad2905eb30cca..a23cc1a8771a5aa5691dcc95c052f98901cc1936 100644 (file)
@@ -104,6 +104,18 @@ void MachineModuleInfo::AnalyzeModule(Module &M) {
       UsedFunctions.insert(F);
 }
 
+/// getAddrLabelSymbol - Return the symbol to be used for the specified basic
+/// block when its address is taken.  This cannot be its normal LBB label
+/// because the block may be accessed outside its containing function.
+MCSymbol *MachineModuleInfo::getAddrLabelSymbol(const BasicBlock *BB) {
+  assert(BB->hasAddressTaken() &&
+         "Shouldn't get label for block without address taken");
+  MCSymbol *&Entry = AddrLabelSymbols[const_cast<BasicBlock*>(BB)];
+  if (Entry) return Entry;
+  return Entry = Context.CreateTempSymbol();
+}
+
+
 //===-EH-------------------------------------------------------------------===//
 
 /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the