diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2011-05-13 21:12:10 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2011-05-13 21:12:10 +0000 |
commit | caf8ffd8e3fb49fd5a5a8a5c907d258277c2b69d (patch) | |
tree | 2c421ee37cc4542ea5d1e6a2d7e482ab4b05d20a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | b9c79ad3331dbca3c94fd7ffce5edd7cea9d50f5 (diff) | |
download | llvm-caf8ffd8e3fb49fd5a5a8a5c907d258277c2b69d.zip llvm-caf8ffd8e3fb49fd5a5a8a5c907d258277c2b69d.tar.gz llvm-caf8ffd8e3fb49fd5a5a8a5c907d258277c2b69d.tar.bz2 |
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.
llvm-svn: 131311
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e4b3210..7cee6b4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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, |