Index: clang/lib/AST/Decl.cpp =================================================================== --- clang/lib/AST/Decl.cpp +++ clang/lib/AST/Decl.cpp @@ -3300,6 +3300,9 @@ if (!getBuiltinID()) return false; + if (getLanguageLinkage() != CLanguageLinkage) + return false; + const FunctionDecl *Definition; return hasBody(Definition) && Definition->isInlineSpecified() && Definition->hasAttr(); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4813,6 +4813,10 @@ if (D.hasAttr()) return true; + FunctionDecl const *FD; + if ((FD = dyn_cast(&D)) && FD->isInlineBuiltinDeclaration()) + return false; + GVALinkage Linkage; if (auto *VD = dyn_cast(&D)) Linkage = CGM.getContext().GetGVALinkageForVariable(VD); Index: clang/test/CodeGen/inline-builtin-asm-name.c =================================================================== --- clang/test/CodeGen/inline-builtin-asm-name.c +++ clang/test/CodeGen/inline-builtin-asm-name.c @@ -1,14 +1,14 @@ // RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -o - %s -disable-llvm-optzns | FileCheck %s +// CHECK-LABEL: define dso_local void @call(ptr noundef %fmt, ...) // CHECK: call i32 @"\01_asm_func_name.inline" - -// CHECK: declare dso_local i32 @"\01_asm_func_name"(ptr noundef, i32 noundef, ptr noundef, ptr noundef) - -// CHECK: define internal i32 @"\01_asm_func_name.inline" - +// +// CHECK-LABEL: declare dso_local i32 @"\01_asm_func_name"(ptr noundef, i32 noundef, ptr noundef, ptr noundef) +// +// CHECK-LABEL: define internal i32 @"\01_asm_func_name.inline"( // CHECK: call i32 @__mingw_vsnprintf - -// CHECK: declare dso_local i32 @__mingw_vsnprintf +// +// CHECK-LABEL: declare dso_local i32 @__mingw_vsnprintf typedef unsigned int size_t; Index: clang/test/CodeGen/inline-builtin-comdat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/inline-builtin-comdat.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s +// Make sure we don't add definition for Inline Builtinsto any comdat. + +double __cdecl frexp( double _X, int* _Y); +inline __attribute__((always_inline)) long double __cdecl frexpl( long double __x, int *__exp ) { + return (long double) frexp((double)__x, __exp ); +} + +long double pain(void) +{ + long double f = 123.45; + int i; + long double f2 = frexpl(f, &i); + return f2; +} + +// CHECK-LABEL: define dso_local double @pain( +// CHECK: call double @frexpl.inline( +// +// CHECK-LABEL: declare dso_local double @frexpl( +// +// CHECK-LABEL: define internal double @frexpl.inline( +// CHECK: call double @frexp +// +// CHECK-LABEL: declare dso_local double @frexp( Index: clang/test/CodeGen/pr9614.c =================================================================== --- clang/test/CodeGen/pr9614.c +++ clang/test/CodeGen/pr9614.c @@ -37,9 +37,9 @@ // CHECK: call void @llvm.prefetch.p0( // CHECK: call ptr @memchr( // CHECK: ret void - -// CHECK: declare void @foo() -// CHECK: declare i32 @abs(i32 -// CHECK: declare ptr @strrchr(ptr noundef, i32 noundef) -// CHECK: declare ptr @memchr( -// CHECK: declare void @llvm.prefetch.p0( +// +// CHECK-LABEL: declare void @foo() +// CHECK-LABEL: declare i32 @abs(i32 +// CHECK-LABEL: declare ptr @strrchr(ptr noundef, i32 noundef) +// CHECK-LABEL: declare ptr @memchr( +// CHECK-LABEL: declare void @llvm.prefetch.p0(