From 34771b594ca8cdf8cd2e40b27170efa4ed2833c5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 14 Sep 2009 04:33:21 +0000 Subject: Fix subtle bug in generating LLVM function declarations for builtin functions. The decl wasn't being passed down, which meant that function attributes were not being set correctly. This is particularly important for ARM, since it wants to override the calling convention. Instead we would emit the builtin with the wrong calling convention, and instcombine would come along and merrily shred all the calls to it. :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81756 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 05f14682d7..fca6ebefda 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1256,7 +1256,8 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { /// getBuiltinLibFunction - Given a builtin id for a function like /// "__builtin_fabsf", return a Function* for "fabsf". -llvm::Value *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) { +llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD, + unsigned BuiltinID) { assert((Context.BuiltinInfo.isLibFunction(BuiltinID) || Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) && "isn't a lib fn"); @@ -1276,8 +1277,7 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) { // Unique the name through the identifier table. Name = getContext().Idents.get(Name).getName(); - // FIXME: param attributes for sext/zext etc. - return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl()); + return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl(FD)); } llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys, -- cgit v1.2.3-18-g5258