[llvm-commits] [llvm] r86189 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Dan Gohman
gohman at apple.com
Thu Nov 5 15:14:35 PST 2009
Author: djg
Date: Thu Nov 5 17:14:35 2009
New Revision: 86189
URL: http://llvm.org/viewvc/llvm-project?rev=86189&view=rev
Log:
Fix the label name generation for address-taken labels to avoid potential
problems with name collisions.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86189&r1=86188&r2=86189&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Nov 5 17:14:35 2009
@@ -1636,13 +1636,17 @@
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 {
More information about the llvm-commits
mailing list