diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index bf34d01751c60913f70e13572226994ace4a2375..e940806094758ca12314e7da56b8a239752fceb2 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -2270,9 +2270,11 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) { if (Writer->Context->getLangOpts().ModulesCodegen) { // Under -fmodules-codegen, codegen is performed for all non-internal, // non-always_inline functions. - if (!Linkage) - Linkage = Writer->Context->GetGVALinkageForFunction(FD); - ModulesCodegen = *Linkage != GVA_Internal; + if (!FD->hasAttr<AlwaysInlineAttr>()) { + if (!Linkage) + Linkage = Writer->Context->GetGVALinkageForFunction(FD); + ModulesCodegen = *Linkage != GVA_Internal; + } } } Record->push_back(ModulesCodegen); diff --git a/test/Modules/Inputs/codegen/foo.h b/test/Modules/Inputs/codegen/foo.h index bd3b6489e710f65a290127bd967382726b19b833..76ad6559cca00e4fdbf1e56c0396069b84e5adab 100644 --- a/test/Modules/Inputs/codegen/foo.h +++ b/test/Modules/Inputs/codegen/foo.h @@ -29,4 +29,7 @@ inline void inst_decl() { inst<float>(); } +__attribute__((always_inline)) inline void always_inl() { +} + asm("narf"); diff --git a/test/Modules/Inputs/codegen/use.cpp b/test/Modules/Inputs/codegen/use.cpp index cd1a4a642d09d0f93979f1774634f87419fa719c..3e551881f6366585794f2d47be435d786ec707a2 100644 --- a/test/Modules/Inputs/codegen/use.cpp +++ b/test/Modules/Inputs/codegen/use.cpp @@ -6,3 +6,6 @@ void non_modular_use_of_implicit_dtor() { void use_of_instantiated_declaration_without_definition() { inst<int>(); } +void call_always_inline() { + always_inl(); +} diff --git a/test/Modules/codegen.test b/test/Modules/codegen.test index 1bdea5df43176e206264db3faf70827fd9e07e3a..a919933da2d248b6a62c480cb10d336e663bbea9 100644 --- a/test/Modules/codegen.test +++ b/test/Modules/codegen.test @@ -4,7 +4,7 @@ REQUIRES: x86-registered-target RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -fmodules-debuginfo -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s -RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s +RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -disable-llvm-passes -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s For want of any better definition, inline asm goes "everywhere" the same as it if it were in a header (with the disadvantage that the inline asm will be @@ -23,6 +23,7 @@ USE: module asm "narf" FOO: $_Z2f1PKcz = comdat any FOO: $_ZN13implicit_dtorD1Ev = comdat any USE: $_Z4instIiEvv = comdat any +USE: $_Z10always_inlv = comdat any FOO: $_ZN13implicit_dtorD2Ev = comdat any FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat FOO: call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}}) @@ -38,6 +39,7 @@ FOO: define weak_odr void @_ZN13implicit_dtorD2Ev USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev USE: define linkonce_odr void @_Z4instIiEvv +USE: define linkonce_odr void @_Z10always_inlv USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev Modular debug info puts the definition of a class defined in a module in that