[llvm-branch-commits] [cfe-branch] r339663 - Merging r339597:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 14 02:20:55 PDT 2018
Author: hans
Date: Tue Aug 14 02:20:55 2018
New Revision: 339663
URL: http://llvm.org/viewvc/llvm-project?rev=339663&view=rev
Log:
Merging r339597:
------------------------------------------------------------------------
r339597 | erichkeane | 2018-08-13 20:33:20 +0200 (Mon, 13 Aug 2018) | 7 lines
Enforce instantiation of template multiversion functions
Multiversioned member functions inside of a template type were
not properly being emitted. The solution to this is to simply
ensure that their bodies are correctly evaluated/assigned during
template instantiation.
------------------------------------------------------------------------
Modified:
cfe/branches/release_70/ (props changed)
cfe/branches/release_70/include/clang/AST/ASTContext.h
cfe/branches/release_70/lib/AST/ASTContext.cpp
cfe/branches/release_70/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/branches/release_70/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
Propchange: cfe/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 14 02:20:55 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339428,339494
+/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339428,339494,339597
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_70/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/include/clang/AST/ASTContext.h?rev=339663&r1=339662&r2=339663&view=diff
==============================================================================
--- cfe/branches/release_70/include/clang/AST/ASTContext.h (original)
+++ cfe/branches/release_70/include/clang/AST/ASTContext.h Tue Aug 14 02:20:55 2018
@@ -2718,7 +2718,7 @@ public:
/// predicate.
void forEachMultiversionedFunctionVersion(
const FunctionDecl *FD,
- llvm::function_ref<void(const FunctionDecl *)> Pred) const;
+ llvm::function_ref<void(FunctionDecl *)> Pred) const;
const CXXConstructorDecl *
getCopyConstructorForExceptionObject(CXXRecordDecl *RD);
Modified: cfe/branches/release_70/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/AST/ASTContext.cpp?rev=339663&r1=339662&r2=339663&view=diff
==============================================================================
--- cfe/branches/release_70/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/release_70/lib/AST/ASTContext.cpp Tue Aug 14 02:20:55 2018
@@ -9811,7 +9811,7 @@ bool ASTContext::DeclMustBeEmitted(const
void ASTContext::forEachMultiversionedFunctionVersion(
const FunctionDecl *FD,
- llvm::function_ref<void(const FunctionDecl *)> Pred) const {
+ llvm::function_ref<void(FunctionDecl *)> Pred) const {
assert(FD->isMultiVersion() && "Only valid for multiversioned functions");
llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
FD = FD->getCanonicalDecl();
Modified: cfe/branches/release_70/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=339663&r1=339662&r2=339663&view=diff
==============================================================================
--- cfe/branches/release_70/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/release_70/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Aug 14 02:20:55 2018
@@ -5192,10 +5192,20 @@ void Sema::PerformPendingInstantiations(
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) {
bool DefinitionRequired = Function->getTemplateSpecializationKind() ==
TSK_ExplicitInstantiationDefinition;
- InstantiateFunctionDefinition(/*FIXME:*/Inst.second, Function, true,
- DefinitionRequired, true);
- if (Function->isDefined())
- Function->setInstantiationIsPending(false);
+ if (Function->isMultiVersion()) {
+ getASTContext().forEachMultiversionedFunctionVersion(
+ Function, [this, Inst, DefinitionRequired](FunctionDecl *CurFD) {
+ InstantiateFunctionDefinition(/*FIXME:*/ Inst.second, CurFD, true,
+ DefinitionRequired, true);
+ if (CurFD->isDefined())
+ CurFD->setInstantiationIsPending(false);
+ });
+ } else {
+ InstantiateFunctionDefinition(/*FIXME:*/ Inst.second, Function, true,
+ DefinitionRequired, true);
+ if (Function->isDefined())
+ Function->setInstantiationIsPending(false);
+ }
continue;
}
Modified: cfe/branches/release_70/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/test/CodeGenCXX/attr-target-mv-member-funcs.cpp?rev=339663&r1=339662&r2=339663&view=diff
==============================================================================
--- cfe/branches/release_70/test/CodeGenCXX/attr-target-mv-member-funcs.cpp (original)
+++ cfe/branches/release_70/test/CodeGenCXX/attr-target-mv-member-funcs.cpp Tue Aug 14 02:20:55 2018
@@ -111,13 +111,12 @@ int templ_use() {
// CHECK: call i32 @_ZN5templIiE3fooEi.ifunc
// CHECK: call i32 @_ZN5templIdE3fooEi.ifunc
-
// CHECK: define i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.resolver() comdat
// CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_sandybridge
// CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_ivybridge
// CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.sse4.2
// CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi
-//
+
// CHECK: define i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.resolver() comdat
// CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_sandybridge
// CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_ivybridge
@@ -135,3 +134,12 @@ int templ_use() {
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi(%struct.S* %this, i32)
// CHECK: ret i32 2
+// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi.sse4.2
+// CHECK: declare i32 @_ZN5templIiE3fooEi.arch_sandybridge
+// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi.arch_ivybridge
+// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi
+
+// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi.sse4.2
+// CHECK: declare i32 @_ZN5templIdE3fooEi.arch_sandybridge
+// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi.arch_ivybridge
+// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi
More information about the llvm-branch-commits
mailing list