summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-02-15 22:23:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-02-15 22:23:51 +0000
commitd62acb569ca062c2786b42107ffa10a158f2d0ed (patch)
tree80f758503e58a8acade52ea3293f9f79a4bfc971 /clang/lib/AST/ItaniumMangle.cpp
parentf35024b08781ef43c7887ebae99eadb2a47728ac (diff)
downloadbcm5719-llvm-d62acb569ca062c2786b42107ffa10a158f2d0ed.tar.gz
bcm5719-llvm-d62acb569ca062c2786b42107ffa10a158f2d0ed.zip
Add a hack to avoid adding '\01' to asm names when possible. It would be
better for clang to always compute the right name, but for now this hack fixes PR9177 and lets us build firefox with LTO :-) llvm-svn: 125607
Diffstat (limited to 'clang/lib/AST/ItaniumMangle.cpp')
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 7d641e45c1f..df6e39b2b3a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -23,6 +23,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/Basic/ABI.h"
#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
@@ -328,7 +329,17 @@ void CXXNameMangler::mangle(const NamedDecl *D, llvm::StringRef Prefix) {
// over all other naming in the .o file.
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
// If we have an asm name, then we use it as the mangling.
- Out << '\01'; // LLVM IR Marker for __asm("foo")
+
+ // Adding the prefix can cause problems when one file has a "foo" and
+ // another has a "\01foo". That is known to happen on ELF with the
+ // tricks normally used for producing aliases (PR9177). Fortunately the
+ // llvm mangler on ELF is a nop, so we can just avoid adding the \01
+ // marker.
+ llvm::StringRef UserLabelPrefix =
+ getASTContext().Target.getUserLabelPrefix();
+ if (!UserLabelPrefix.empty())
+ Out << '\01'; // LLVM IR Marker for __asm("foo")
+
Out << ALA->getLabel();
return;
}
OpenPOWER on IntegriCloud