@@ -969,7 +969,7 @@ void IRGenerator::emitEagerClassInitialization() {
969
969
false /* = isVarArg */ );
970
970
llvm::InlineAsm *inlineAsm =
971
971
llvm::InlineAsm::get (asmFnTy, " " , " r" , true /* = SideEffects */ );
972
- RegisterIGF.Builder .CreateCall (inlineAsm, MetaData);
972
+ RegisterIGF.Builder .CreateAsmCall (inlineAsm, MetaData);
973
973
}
974
974
RegisterIGF.Builder .CreateRetVoid ();
975
975
@@ -1535,17 +1535,15 @@ static bool isPointerTo(llvm::Type *ptrTy, llvm::Type *objTy) {
1535
1535
}
1536
1536
1537
1537
// / Get or create an LLVM function with these linkage rules.
1538
- llvm::Function *swift::irgen::createFunction (IRGenModule &IGM,
1539
- LinkInfo &linkInfo,
1540
- llvm::FunctionType *fnType,
1541
- llvm::CallingConv::ID cc,
1542
- const llvm::AttributeSet &attrs,
1543
- llvm::Function *insertBefore) {
1538
+ llvm::Function *irgen::createFunction (IRGenModule &IGM,
1539
+ LinkInfo &linkInfo,
1540
+ const Signature &signature,
1541
+ llvm::Function *insertBefore) {
1544
1542
auto name = linkInfo.getName ();
1545
1543
1546
1544
llvm::Function *existing = IGM.Module .getFunction (name);
1547
1545
if (existing) {
1548
- if (isPointerTo (existing->getType (), fnType ))
1546
+ if (isPointerTo (existing->getType (), signature. getType () ))
1549
1547
return cast<llvm::Function>(existing);
1550
1548
1551
1549
IGM.error (SourceLoc (),
@@ -1557,10 +1555,10 @@ llvm::Function *swift::irgen::createFunction(IRGenModule &IGM,
1557
1555
}
1558
1556
1559
1557
llvm::Function *fn =
1560
- llvm::Function::Create (fnType , linkInfo.getLinkage (), name);
1558
+ llvm::Function::Create (signature. getType () , linkInfo.getLinkage (), name);
1561
1559
fn->setVisibility (linkInfo.getVisibility ());
1562
1560
fn->setDLLStorageClass (linkInfo.getDLLStorage ());
1563
- fn->setCallingConv (cc );
1561
+ fn->setCallingConv (signature. getCallingConv () );
1564
1562
1565
1563
if (insertBefore) {
1566
1564
IGM.Module .getFunctionList ().insert (insertBefore->getIterator (), fn);
@@ -1570,8 +1568,10 @@ llvm::Function *swift::irgen::createFunction(IRGenModule &IGM,
1570
1568
1571
1569
auto initialAttrs = IGM.constructInitialAttributes ();
1572
1570
// Merge initialAttrs with attrs.
1573
- auto updatedAttrs = attrs.addAttributes (IGM.getLLVMContext (),
1574
- llvm::AttributeSet::FunctionIndex, initialAttrs);
1571
+ auto updatedAttrs =
1572
+ signature.getAttributes ().addAttributes (IGM.getLLVMContext (),
1573
+ llvm::AttributeSet::FunctionIndex,
1574
+ initialAttrs);
1575
1575
if (!updatedAttrs.isEmpty ())
1576
1576
fn->setAttributes (updatedAttrs);
1577
1577
@@ -1897,21 +1897,19 @@ llvm::Function *IRGenModule::getAddrOfSILFunction(SILFunction *f,
1897
1897
}
1898
1898
1899
1899
Signature signature = getSignature (f->getLoweredFunctionType ());
1900
- llvm::FunctionType *fnType = signature.getType ();
1901
- auto cc = signature.getCallingConv ();
1902
- auto attrs = signature.getAttributes ();
1900
+ auto &attrs = signature.getMutableAttributes ();
1903
1901
1904
1902
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
1905
1903
1906
1904
if (f->getInlineStrategy () == NoInline) {
1907
- attrs = attrs.addAttribute (fnType-> getContext (),
1905
+ attrs = attrs.addAttribute (getLLVMContext (),
1908
1906
llvm::AttributeSet::FunctionIndex, llvm::Attribute::NoInline);
1909
1907
}
1910
1908
if (isReadOnlyFunction (f)) {
1911
- attrs = attrs.addAttribute (fnType-> getContext (),
1909
+ attrs = attrs.addAttribute (getLLVMContext (),
1912
1910
llvm::AttributeSet::FunctionIndex, llvm::Attribute::ReadOnly);
1913
1911
}
1914
- fn = createFunction (*this , link, fnType, cc, attrs , insertBefore);
1912
+ fn = createFunction (*this , link, signature , insertBefore);
1915
1913
1916
1914
// If we have an order number for this function, set it up as appropriate.
1917
1915
if (hasOrderNumber) {
@@ -2511,8 +2509,9 @@ IRGenModule::getAddrOfTypeMetadataAccessFunction(CanType type,
2511
2509
}
2512
2510
2513
2511
auto fnType = llvm::FunctionType::get (TypeMetadataPtrTy, false );
2512
+ Signature signature (fnType, llvm::AttributeSet (), DefaultCC);
2514
2513
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
2515
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
2514
+ entry = createFunction (*this , link, signature );
2516
2515
return entry;
2517
2516
}
2518
2517
@@ -2536,8 +2535,9 @@ IRGenModule::getAddrOfGenericTypeMetadataAccessFunction(
2536
2535
}
2537
2536
2538
2537
auto fnType = llvm::FunctionType::get (TypeMetadataPtrTy, genericArgs, false );
2538
+ Signature signature (fnType, llvm::AttributeSet (), DefaultCC);
2539
2539
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
2540
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
2540
+ entry = createFunction (*this , link, signature );
2541
2541
return entry;
2542
2542
}
2543
2543
@@ -2846,13 +2846,9 @@ llvm::Function *IRGenModule::getAddrOfValueWitness(CanType abstractType,
2846
2846
return entry;
2847
2847
}
2848
2848
2849
- // Find the appropriate function type.
2850
- llvm::FunctionType *fnType =
2851
- cast<llvm::FunctionType>(
2852
- cast<llvm::PointerType>(getValueWitnessTy (index))
2853
- ->getElementType ());
2849
+ auto signature = getValueWitnessSignature (index);
2854
2850
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
2855
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
2851
+ entry = createFunction (*this , link, signature );
2856
2852
return entry;
2857
2853
}
2858
2854
@@ -3326,8 +3322,9 @@ IRGenModule::getAddrOfGenericWitnessTableInstantiationFunction(
3326
3322
TypeMetadataPtrTy,
3327
3323
Int8PtrPtrTy },
3328
3324
/* varargs*/ false );
3325
+ Signature signature (fnType, llvm::AttributeSet (), DefaultCC);
3329
3326
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
3330
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
3327
+ entry = createFunction (*this , link, signature );
3331
3328
return entry;
3332
3329
}
3333
3330
@@ -3374,8 +3371,9 @@ IRGenModule::getAddrOfWitnessTableAccessFunction(
3374
3371
fnType = llvm::FunctionType::get (WitnessTablePtrTy, false );
3375
3372
}
3376
3373
3374
+ Signature signature (fnType, llvm::AttributeSet (), DefaultCC);
3377
3375
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
3378
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
3376
+ entry = createFunction (*this , link, signature );
3379
3377
return entry;
3380
3378
}
3381
3379
@@ -3396,8 +3394,9 @@ IRGenModule::getAddrOfWitnessTableLazyAccessFunction(
3396
3394
llvm::FunctionType *fnType
3397
3395
= llvm::FunctionType::get (WitnessTablePtrTy, false );
3398
3396
3397
+ Signature signature (fnType, llvm::AttributeSet (), DefaultCC);
3399
3398
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
3400
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
3399
+ entry = createFunction (*this , link, signature );
3401
3400
return entry;
3402
3401
}
3403
3402
@@ -3446,9 +3445,9 @@ IRGenModule::getAddrOfAssociatedTypeMetadataAccessFunction(
3446
3445
return entry;
3447
3446
}
3448
3447
3449
- auto fnType = getAssociatedTypeMetadataAccessFunctionTy ();
3448
+ auto signature = getAssociatedTypeMetadataAccessFunctionSignature ();
3450
3449
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
3451
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
3450
+ entry = createFunction (*this , link, signature );
3452
3451
return entry;
3453
3452
}
3454
3453
@@ -3469,9 +3468,9 @@ IRGenModule::getAddrOfAssociatedTypeWitnessTableAccessFunction(
3469
3468
return entry;
3470
3469
}
3471
3470
3472
- auto fnType = getAssociatedTypeWitnessTableAccessFunctionTy ();
3471
+ auto signature = getAssociatedTypeWitnessTableAccessFunctionSignature ();
3473
3472
LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
3474
- entry = createFunction (*this , link, fnType, DefaultCC, llvm::AttributeSet () );
3473
+ entry = createFunction (*this , link, signature );
3475
3474
return entry;
3476
3475
}
3477
3476
0 commit comments