@@ -3414,22 +3414,12 @@ void CodeGenModule::EmitTargetClonesResolver(GlobalDecl GD) {
3414
3414
const auto *TC = FD->getAttr <TargetClonesAttr>();
3415
3415
assert (TC && " Not a target_clones Function?" );
3416
3416
3417
- QualType CanonTy = Context.getCanonicalType (FD->getType ());
3418
- llvm::Type *DeclTy = getTypes ().ConvertType (CanonTy);
3419
-
3420
- if (const auto *CXXFD = dyn_cast<CXXMethodDecl>(FD)) {
3421
- const CGFunctionInfo &FInfo = getTypes ().arrangeCXXMethodDeclaration (CXXFD);
3422
- DeclTy = getTypes ().GetFunctionType (FInfo);
3423
- }
3424
-
3425
3417
llvm::Function *ResolverFunc;
3426
3418
if (getTarget ().supportsIFunc ()) {
3427
- auto *IFunc = cast<llvm::GlobalIFunc>(
3428
- GetOrCreateMultiVersionResolver (GD, DeclTy, FD));
3419
+ auto *IFunc = cast<llvm::GlobalIFunc>(GetOrCreateMultiVersionResolver (GD));
3429
3420
ResolverFunc = cast<llvm::Function>(IFunc->getResolver ());
3430
3421
} else
3431
- ResolverFunc =
3432
- cast<llvm::Function>(GetOrCreateMultiVersionResolver (GD, DeclTy, FD));
3422
+ ResolverFunc = cast<llvm::Function>(GetOrCreateMultiVersionResolver (GD));
3433
3423
3434
3424
SmallVector<CodeGenFunction::MultiVersionResolverOption, 10 > Options;
3435
3425
for (unsigned VersionIndex = 0 ; VersionIndex < TC->featuresStrs_size ();
@@ -3545,12 +3535,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
3545
3535
assert (FD->isCPUDispatchMultiVersion () && " Not a multiversion function?" );
3546
3536
const auto *DD = FD->getAttr <CPUDispatchAttr>();
3547
3537
assert (DD && " Not a cpu_dispatch Function?" );
3548
- llvm::Type *DeclTy = getTypes ().ConvertType (FD->getType ());
3549
3538
3550
- if (const auto *CXXFD = dyn_cast<CXXMethodDecl>(FD)) {
3551
- const CGFunctionInfo &FInfo = getTypes ().arrangeCXXMethodDeclaration (CXXFD);
3552
- DeclTy = getTypes ().GetFunctionType (FInfo);
3553
- }
3539
+ const CGFunctionInfo &FI = getTypes ().arrangeGlobalDeclaration (GD);
3540
+ llvm::FunctionType *DeclTy = getTypes ().GetFunctionType (FI);
3554
3541
3555
3542
StringRef ResolverName = getMangledName (GD);
3556
3543
UpdateMultiVersionNames (GD, FD, ResolverName);
@@ -3640,8 +3627,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
3640
3627
3641
3628
if (getTarget ().supportsIFunc ()) {
3642
3629
llvm::GlobalValue::LinkageTypes Linkage = getMultiversionLinkage (*this , GD);
3643
- auto *IFunc = cast<llvm::GlobalValue>(
3644
- GetOrCreateMultiVersionResolver (GD, DeclTy, FD));
3630
+ auto *IFunc = cast<llvm::GlobalValue>(GetOrCreateMultiVersionResolver (GD));
3645
3631
3646
3632
// Fix up function declarations that were created for cpu_specific before
3647
3633
// cpu_dispatch was known
@@ -3668,8 +3654,10 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
3668
3654
3669
3655
// / If a dispatcher for the specified mangled name is not in the module, create
3670
3656
// / and return an llvm Function with the specified type.
3671
- llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver (
3672
- GlobalDecl GD, llvm::Type *DeclTy, const FunctionDecl *FD) {
3657
+ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver (GlobalDecl GD) {
3658
+ const auto *FD = cast<FunctionDecl>(GD.getDecl ());
3659
+ assert (FD && " Not a FunctionDecl?" );
3660
+
3673
3661
std::string MangledName =
3674
3662
getMangledNameImpl (*this , GD, FD, /* OmitMultiVersionMangling=*/ true );
3675
3663
@@ -3685,6 +3673,9 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(
3685
3673
if (llvm::GlobalValue *ResolverGV = GetGlobalValue (ResolverName))
3686
3674
return ResolverGV;
3687
3675
3676
+ const CGFunctionInfo &FI = getTypes ().arrangeGlobalDeclaration (GD);
3677
+ llvm::FunctionType *DeclTy = getTypes ().GetFunctionType (FI);
3678
+
3688
3679
// Since this is the first time we've created this IFunc, make sure
3689
3680
// that we put this multiversioned function into the list to be
3690
3681
// replaced later if necessary (target multiversioning only).
@@ -3770,7 +3761,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
3770
3761
if (FD->isMultiVersion ()) {
3771
3762
UpdateMultiVersionNames (GD, FD, MangledName);
3772
3763
if (!IsForDefinition)
3773
- return GetOrCreateMultiVersionResolver (GD, Ty, FD );
3764
+ return GetOrCreateMultiVersionResolver (GD);
3774
3765
}
3775
3766
}
3776
3767
0 commit comments