serge-sans-paille updated this revision to Diff 523747. serge-sans-paille retitled this revision from "[clang] Enforce external linkage for inline builtin original declaration" to "[clang] Fix comdat for InlineBuiltin declarations". serge-sans-paille edited the summary of this revision.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148723/new/ https://reviews.llvm.org/D148723 Files: clang/lib/AST/Decl.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGen/inline-builtin-asm-name.c clang/test/CodeGen/inline-builtin-comdat.c clang/test/CodeGen/pr9614.c
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( 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/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/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4813,6 +4813,10 @@ if (D.hasAttr<SelectAnyAttr>()) return true; + FunctionDecl const *FD; + if ((FD = dyn_cast<FunctionDecl>(&D)) && FD->isInlineBuiltinDeclaration()) + return false; + GVALinkage Linkage; if (auto *VD = dyn_cast<VarDecl>(&D)) Linkage = CGM.getContext().GetGVALinkageForVariable(VD); 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<AlwaysInlineAttr>();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits