Skip to content

Commit d0d8eb2

Browse files
committed
Merging r345839:
------------------------------------------------------------------------ r345839 | erichkeane | 2018-11-01 08:11:43 -0700 (Thu, 01 Nov 2018) | 6 lines Multiversioning- Ensure all MV functions are emitted. Multiverson function versions are always used (by the resolver), so ensure that they are always emitted. Change-Id: I5d2e0841fddf0d18918b3fb92ae76814add7ee96 ------------------------------------------------------------------------ llvm-svn: 348686
1 parent 0a9b9e6 commit d0d8eb2

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9734,6 +9734,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
97349734
return true;
97359735

97369736
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
9737+
// Multiversioned functions always have to be emitted, because they are used
9738+
// by the resolver.
9739+
if (FD->isMultiVersion())
9740+
return true;
97379741
// Forward declarations aren't required.
97389742
if (!FD->doesThisDeclarationHaveABody())
97399743
return FD->doesDeclarationForceExternallyVisibleDefinition();

clang/test/CodeGenCXX/attr-cpuspecific.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ void foo() {
1212
s.Func();
1313
}
1414

15+
// LINUX: define linkonce_odr void @_ZN1S4FuncEv.O
1516
// LINUX: define void (%struct.S*)* @_ZN1S4FuncEv.resolver
1617
// LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.S
1718
// LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.O

clang/test/CodeGenCXX/attr-target-mv-member-funcs.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ int templ_use() {
7272
// CHECK: @_ZN5templIiE3fooEi.ifunc = ifunc i32 (%struct.templ*, i32), i32 (%struct.templ*, i32)* ()* @_ZN5templIiE3fooEi.resolver
7373
// CHECK: @_ZN5templIdE3fooEi.ifunc = ifunc i32 (%struct.templ.0*, i32), i32 (%struct.templ.0*, i32)* ()* @_ZN5templIdE3fooEi.resolver
7474

75+
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi.sse4.2(%struct.S* %this, i32)
76+
// CHECK: ret i32 0
77+
78+
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi.arch_ivybridge(%struct.S* %this, i32)
79+
// CHECK: ret i32 1
80+
81+
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi(%struct.S* %this, i32)
82+
// CHECK: ret i32 2
83+
7584
// CHECK: define i32 @_Z3barv()
7685
// CHECK: %s = alloca %struct.S, align 1
7786
// CHECK: %s2 = alloca %struct.S, align 1
@@ -123,23 +132,14 @@ int templ_use() {
123132
// CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.sse4.2
124133
// CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi
125134

126-
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi.sse4.2(%struct.S* %this, i32)
127-
// CHECK: ret i32 0
128-
129-
// CHECK: declare i32 @_ZN1S3fooEi.arch_sandybridge(%struct.S*, i32)
130-
131-
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi.arch_ivybridge(%struct.S* %this, i32)
132-
// CHECK: ret i32 1
133-
134-
// CHECK: define linkonce_odr i32 @_ZN1S3fooEi(%struct.S* %this, i32)
135-
// CHECK: ret i32 2
136-
137135
// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi.sse4.2
138-
// CHECK: declare i32 @_ZN5templIiE3fooEi.arch_sandybridge
139136
// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi.arch_ivybridge
140137
// CHECK: define linkonce_odr i32 @_ZN5templIiE3fooEi
141138

142139
// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi.sse4.2
143-
// CHECK: declare i32 @_ZN5templIdE3fooEi.arch_sandybridge
144140
// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi.arch_ivybridge
145141
// CHECK: define linkonce_odr i32 @_ZN5templIdE3fooEi
142+
//
143+
// CHECK: declare i32 @_ZN1S3fooEi.arch_sandybridge(%struct.S*, i32)
144+
// CHECK: declare i32 @_ZN5templIiE3fooEi.arch_sandybridge
145+
// CHECK: declare i32 @_ZN5templIdE3fooEi.arch_sandybridge

0 commit comments

Comments
 (0)