@@ -4443,12 +4443,13 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
4443
4443
if (getTarget ().supportsIFunc ()) {
4444
4444
llvm::GlobalValue::LinkageTypes Linkage = getMultiversionLinkage (*this , GD);
4445
4445
auto *IFunc = cast<llvm::GlobalValue>(GetOrCreateMultiVersionResolver (GD));
4446
+ unsigned AS = IFunc->getType ()->getPointerAddressSpace ();
4446
4447
4447
4448
// Fix up function declarations that were created for cpu_specific before
4448
4449
// cpu_dispatch was known
4449
4450
if (!isa<llvm::GlobalIFunc>(IFunc)) {
4450
- auto *GI = llvm::GlobalIFunc::create (DeclTy, 0 , Linkage, " " , ResolverFunc ,
4451
- &getModule ());
4451
+ auto *GI = llvm::GlobalIFunc::create (DeclTy, AS , Linkage, " " ,
4452
+ ResolverFunc, &getModule ());
4452
4453
replaceDeclarationWith (IFunc, GI);
4453
4454
IFunc = GI;
4454
4455
}
@@ -4457,8 +4458,8 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
4457
4458
*this , GD, FD, /* OmitMultiVersionMangling=*/ true );
4458
4459
llvm::Constant *AliasFunc = GetGlobalValue (AliasName);
4459
4460
if (!AliasFunc) {
4460
- auto *GA = llvm::GlobalAlias::create (DeclTy, 0 , Linkage, AliasName, IFunc ,
4461
- &getModule ());
4461
+ auto *GA = llvm::GlobalAlias::create (DeclTy, AS , Linkage, AliasName,
4462
+ IFunc, &getModule ());
4462
4463
SetCommonAttributes (GD, GA);
4463
4464
}
4464
4465
}
@@ -4530,15 +4531,14 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
4530
4531
// For cpu_specific, don't create an ifunc yet because we don't know if the
4531
4532
// cpu_dispatch will be emitted in this translation unit.
4532
4533
if (getTarget ().supportsIFunc () && !FD->isCPUSpecificMultiVersion ()) {
4533
- llvm::Type *ResolverType = llvm::FunctionType::get (
4534
- llvm::PointerType::get (DeclTy,
4535
- getTypes ().getTargetAddressSpace (FD->getType ())),
4536
- false );
4534
+ unsigned AS = getTypes ().getTargetAddressSpace (FD->getType ());
4535
+ llvm::Type *ResolverType =
4536
+ llvm::FunctionType::get (llvm::PointerType::get (DeclTy, AS), false );
4537
4537
llvm::Constant *Resolver = GetOrCreateLLVMFunction (
4538
4538
MangledName + " .resolver" , ResolverType, GlobalDecl{},
4539
4539
/* ForVTable=*/ false );
4540
4540
llvm::GlobalIFunc *GIF =
4541
- llvm::GlobalIFunc::create (DeclTy, 0 , getMultiversionLinkage (*this , GD),
4541
+ llvm::GlobalIFunc::create (DeclTy, AS , getMultiversionLinkage (*this , GD),
4542
4542
" " , Resolver, &getModule ());
4543
4543
GIF->setName (ResolverName);
4544
4544
SetCommonAttributes (FD, GIF);
@@ -6144,9 +6144,9 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
6144
6144
GetOrCreateLLVMFunction (IFA->getResolver (), VoidTy, {},
6145
6145
/* ForVTable=*/ false );
6146
6146
llvm::Type *DeclTy = getTypes ().ConvertTypeForMem (D->getType ());
6147
- llvm::GlobalIFunc *GIF =
6148
- llvm::GlobalIFunc::create (DeclTy, 0 , llvm::Function::ExternalLinkage,
6149
- " " , Resolver, &getModule ());
6147
+ unsigned AS = getTypes (). getTargetAddressSpace (D-> getType ());
6148
+ llvm::GlobalIFunc *GIF = llvm::GlobalIFunc::create (
6149
+ DeclTy, AS, llvm::Function::ExternalLinkage, " " , Resolver, &getModule ());
6150
6150
if (Entry) {
6151
6151
if (GIF->getResolver () == Entry) {
6152
6152
Diags.Report (IFA->getLocation (), diag::err_cyclic_alias) << 1 ;
0 commit comments