@@ -4455,12 +4455,13 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
4455
4455
if (getTarget ().supportsIFunc ()) {
4456
4456
llvm::GlobalValue::LinkageTypes Linkage = getMultiversionLinkage (*this , GD);
4457
4457
auto *IFunc = cast<llvm::GlobalValue>(GetOrCreateMultiVersionResolver (GD));
4458
+ unsigned AS = IFunc->getType ()->getPointerAddressSpace ();
4458
4459
4459
4460
// Fix up function declarations that were created for cpu_specific before
4460
4461
// cpu_dispatch was known
4461
4462
if (!isa<llvm::GlobalIFunc>(IFunc)) {
4462
- auto *GI = llvm::GlobalIFunc::create (DeclTy, 0 , Linkage, " " , ResolverFunc ,
4463
- &getModule ());
4463
+ auto *GI = llvm::GlobalIFunc::create (DeclTy, AS , Linkage, " " ,
4464
+ ResolverFunc, &getModule ());
4464
4465
replaceDeclarationWith (IFunc, GI);
4465
4466
IFunc = GI;
4466
4467
}
@@ -4469,8 +4470,8 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
4469
4470
*this , GD, FD, /* OmitMultiVersionMangling=*/ true );
4470
4471
llvm::Constant *AliasFunc = GetGlobalValue (AliasName);
4471
4472
if (!AliasFunc) {
4472
- auto *GA = llvm::GlobalAlias::create (DeclTy, 0 , Linkage, AliasName, IFunc ,
4473
- &getModule ());
4473
+ auto *GA = llvm::GlobalAlias::create (DeclTy, AS , Linkage, AliasName,
4474
+ IFunc, &getModule ());
4474
4475
SetCommonAttributes (GD, GA);
4475
4476
}
4476
4477
}
@@ -4542,15 +4543,14 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
4542
4543
// For cpu_specific, don't create an ifunc yet because we don't know if the
4543
4544
// cpu_dispatch will be emitted in this translation unit.
4544
4545
if (getTarget ().supportsIFunc () && !FD->isCPUSpecificMultiVersion ()) {
4545
- llvm::Type *ResolverType = llvm::FunctionType::get (
4546
- llvm::PointerType::get (DeclTy,
4547
- getTypes ().getTargetAddressSpace (FD->getType ())),
4548
- false );
4546
+ unsigned AS = getTypes ().getTargetAddressSpace (FD->getType ());
4547
+ llvm::Type *ResolverType =
4548
+ llvm::FunctionType::get (llvm::PointerType::get (DeclTy, AS), false );
4549
4549
llvm::Constant *Resolver = GetOrCreateLLVMFunction (
4550
4550
MangledName + " .resolver" , ResolverType, GlobalDecl{},
4551
4551
/* ForVTable=*/ false );
4552
4552
llvm::GlobalIFunc *GIF =
4553
- llvm::GlobalIFunc::create (DeclTy, 0 , getMultiversionLinkage (*this , GD),
4553
+ llvm::GlobalIFunc::create (DeclTy, AS , getMultiversionLinkage (*this , GD),
4554
4554
" " , Resolver, &getModule ());
4555
4555
GIF->setName (ResolverName);
4556
4556
SetCommonAttributes (FD, GIF);
@@ -6160,9 +6160,9 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
6160
6160
GetOrCreateLLVMFunction (IFA->getResolver (), VoidTy, {},
6161
6161
/* ForVTable=*/ false );
6162
6162
llvm::Type *DeclTy = getTypes ().ConvertTypeForMem (D->getType ());
6163
- llvm::GlobalIFunc *GIF =
6164
- llvm::GlobalIFunc::create (DeclTy, 0 , llvm::Function::ExternalLinkage,
6165
- " " , Resolver, &getModule ());
6163
+ unsigned AS = getTypes (). getTargetAddressSpace (D-> getType ());
6164
+ llvm::GlobalIFunc *GIF = llvm::GlobalIFunc::create (
6165
+ DeclTy, AS, llvm::Function::ExternalLinkage, " " , Resolver, &getModule ());
6166
6166
if (Entry) {
6167
6167
if (GIF->getResolver () == Entry) {
6168
6168
Diags.Report (IFA->getLocation (), diag::err_cyclic_alias) << 1 ;
0 commit comments