summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-11-05 23:14:35 +0000
committerDan Gohman <gohman@apple.com>2009-11-05 23:14:35 +0000
commitd53b5cfe3ff41cac991a190acaf6fdd96f4d47a7 (patch)
treea02fa68ecca907a5a497084b649c86ca680a6fd0
parent563265720823e05d28bd13effa77465aaf291a25 (diff)
downloadbcm5719-llvm-d53b5cfe3ff41cac991a190acaf6fdd96f4d47a7.tar.gz
bcm5719-llvm-d53b5cfe3ff41cac991a190acaf6fdd96f4d47a7.zip
Fix the label name generation for address-taken labels to avoid potential
problems with name collisions. llvm-svn: 86189
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index bb6bd957f06..4c4e0d311b0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1636,13 +1636,17 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
assert(BB->hasName() &&
"Address of anonymous basic block not supported yet!");
- // FIXME: This isn't guaranteed to produce a unique name even if the
- // block and function have a name.
- std::string Mangled =
- Mang->getMangledName(F, Mang->makeNameProper(BB->getName()).c_str(),
- /*ForcePrivate=*/true);
+ // This code must use the function name itself, and not the function number,
+ // since it must be possible to generate the label name from within other
+ // functions.
+ std::string FuncName = Mang->getMangledName(F);
- return OutContext.GetOrCreateSymbol(StringRef(Mangled));
+ SmallString<60> Name;
+ raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BA"
+ << FuncName.size() << '_' << FuncName << '_'
+ << Mang->makeNameProper(BB->getName());
+
+ return OutContext.GetOrCreateSymbol(Name.str());
}
MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
OpenPOWER on IntegriCloud