Skip to content

Commit aff962d

Browse files
committed
[clang][FMV] Fix crash with cpu_specific attribute.
Raised here #115299. The commit a2d3099 introduced `replaceDeclarationWith`, but it shouldn't be called by the fallthrough code which handles the cpu_specific attribute.
1 parent a5d09f4 commit aff962d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,8 +4597,6 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
45974597
assert(isa<llvm::GlobalValue>(Resolver) &&
45984598
"Resolver should be created for the first time");
45994599
SetCommonAttributes(FD, cast<llvm::GlobalValue>(Resolver));
4600-
if (ResolverGV)
4601-
replaceDeclarationWith(ResolverGV, Resolver);
46024600
return Resolver;
46034601
}
46044602

clang/test/CodeGen/attr-cpuspecific.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ void ThreeVersionsSameAttr(void){}
114114
// CHECK: define {{.*}}void @ThreeVersionsSameAttr.Z() #[[K]]
115115

116116
ATTR(cpu_specific(knl))
117-
void CpuSpecificNoDispatch(void) {}
118-
// CHECK: define {{.*}}void @CpuSpecificNoDispatch.Z() #[[K:[0-9]+]]
117+
void CpuSpecificNoDispatch(void (*f)(void)) {}
118+
// CHECK: define {{.*}}void @CpuSpecificNoDispatch.Z(ptr noundef %f) #[[K:[0-9]+]]
119119

120120
ATTR(cpu_dispatch(knl))
121121
void OrderDispatchUsageSpecific(void);
@@ -151,9 +151,9 @@ void usages(void) {
151151
ThreeVersionsSameAttr();
152152
// LINUX: @ThreeVersionsSameAttr.ifunc()
153153
// WINDOWS: @ThreeVersionsSameAttr()
154-
CpuSpecificNoDispatch();
155-
// LINUX: @CpuSpecificNoDispatch.ifunc()
156-
// WINDOWS: @CpuSpecificNoDispatch()
154+
CpuSpecificNoDispatch((void (*)(void))CpuSpecificNoDispatch);
155+
// LINUX: @CpuSpecificNoDispatch.ifunc(ptr noundef @CpuSpecificNoDispatch.ifunc)
156+
// WINDOWS: @CpuSpecificNoDispatch(ptr noundef @CpuSpecificNoDispatch)
157157
OrderDispatchUsageSpecific();
158158
// LINUX: @OrderDispatchUsageSpecific.ifunc()
159159
// WINDOWS: @OrderDispatchUsageSpecific()
@@ -162,7 +162,7 @@ void usages(void) {
162162
// WINDOWS: @OrderSpecificUsageDispatch()
163163
}
164164

165-
// LINUX: declare void @CpuSpecificNoDispatch.ifunc()
165+
// LINUX: declare void @CpuSpecificNoDispatch.ifunc(ptr)
166166

167167
// has an extra config to emit!
168168
ATTR(cpu_dispatch(ivybridge, knl, atom))

0 commit comments

Comments
 (0)