aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2011-05-13 21:12:10 +0000
committerJoerg Sonnenberger <joerg@bec.de>2011-05-13 21:12:10 +0000
commit4fe497d5cd34a7dca6e68b2e0a00fe2293570742 (patch)
treee44d8d5121f115e8e1949754988779dff1dc3602 /lib/CodeGen/CodeGenModule.cpp
parentcbea7635a9a33fe768ed9611b57beae23bd7c98e (diff)
Bug 8765: Honor assembler labels for builtins. Ensure that the label is
mangled to avoid doing it twice for platforms that use prefixes like Darwin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index e4b3210d1e..7cee6b4565 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1574,14 +1574,24 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
"isn't a lib fn");
// Get the name, skip over the __builtin_ prefix (if necessary).
- const char *Name = Context.BuiltinInfo.GetName(BuiltinID);
- if (Context.BuiltinInfo.isLibFunction(BuiltinID))
- Name += 10;
+ llvm::StringRef Name;
+ GlobalDecl D(FD);
+
+ // If the builtin has been declared explicitly with an assembler label,
+ // use the mangled name. This differs from the plain label on platforms
+ // that prefix labels.
+ if (const AsmLabelAttr *ALA = FD->getAttr<AsmLabelAttr>())
+ Name = getMangledName(D);
+ else if (Context.BuiltinInfo.isLibFunction(BuiltinID))
+ Name = Context.BuiltinInfo.GetName(BuiltinID) + 10;
+ else
+ Name = Context.BuiltinInfo.GetName(BuiltinID);
+
const llvm::FunctionType *Ty =
cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType()));
- return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl(FD), /*ForVTable=*/false);
+ return GetOrCreateLLVMFunction(Name, Ty, D, /*ForVTable=*/false);
}
llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys,