@@ -45,10 +45,12 @@ bool BuiltinInfo::isReadNone() const {
45
45
}
46
46
47
47
bool IntrinsicInfo::hasAttribute (llvm::Attribute::AttrKind Kind) const {
48
- // FIXME: We should not be relying on the global LLVM context.
49
- llvm::AttributeList attrs =
50
- llvm::Intrinsic::getAttributes (getGlobalLLVMContext (), ID);
51
- return (attrs.hasAttribute (llvm::AttributeList::FunctionIndex, Kind));
48
+ using DenseMapInfo = llvm::DenseMapInfo<llvm::AttributeList>;
49
+ if (DenseMapInfo::isEqual (Attrs, DenseMapInfo::getEmptyKey ())) {
50
+ // FIXME: We should not be relying on the global LLVM context.
51
+ Attrs = llvm::Intrinsic::getAttributes (getGlobalLLVMContext (), ID);
52
+ }
53
+ return Attrs.hasFnAttribute (Kind);
52
54
}
53
55
54
56
Type swift::getBuiltinType (ASTContext &Context, StringRef Name) {
@@ -1223,10 +1225,7 @@ static const char *const IntrinsicNameTable[] = {
1223
1225
#include " llvm/IR/IntrinsicImpl.inc"
1224
1226
#undef GET_INTRINSIC_TARGET_DATA
1225
1227
1226
- // / getLLVMIntrinsicID - Given an LLVM IR intrinsic name with argument types
1227
- // / removed (e.g. like "bswap") return the LLVM IR IntrinsicID for the intrinsic
1228
- // / or 0 if the intrinsic name doesn't match anything.
1229
- unsigned swift::getLLVMIntrinsicID (StringRef InName) {
1228
+ llvm::Intrinsic::ID swift::getLLVMIntrinsicID (StringRef InName) {
1230
1229
using namespace llvm ;
1231
1230
1232
1231
// Swift intrinsic names start with int_.
@@ -1319,12 +1318,11 @@ static Type DecodeIntrinsicType(ArrayRef<llvm::Intrinsic::IITDescriptor> &Table,
1319
1318
1320
1319
// / \returns true on success, false on failure.
1321
1320
static bool
1322
- getSwiftFunctionTypeForIntrinsic (unsigned iid, ArrayRef<Type> TypeArgs,
1321
+ getSwiftFunctionTypeForIntrinsic (llvm::Intrinsic::ID ID,
1322
+ ArrayRef<Type> TypeArgs,
1323
1323
ASTContext &Context,
1324
1324
SmallVectorImpl<Type> &ArgElts,
1325
- Type &ResultTy, FunctionType::ExtInfo &Info) {
1326
- llvm::Intrinsic::ID ID = (llvm::Intrinsic::ID)iid;
1327
-
1325
+ Type &ResultTy) {
1328
1326
typedef llvm::Intrinsic::IITDescriptor IITDescriptor;
1329
1327
SmallVector<IITDescriptor, 8 > Table;
1330
1328
getIntrinsicInfoTableEntries (ID, Table);
@@ -1346,7 +1344,6 @@ getSwiftFunctionTypeForIntrinsic(unsigned iid, ArrayRef<Type> TypeArgs,
1346
1344
// Translate LLVM function attributes to Swift function attributes.
1347
1345
llvm::AttributeList attrs =
1348
1346
llvm::Intrinsic::getAttributes (getGlobalLLVMContext (), ID);
1349
- Info = FunctionType::ExtInfo ();
1350
1347
if (attrs.hasAttribute (llvm::AttributeList::FunctionIndex,
1351
1348
llvm::Attribute::NoReturn)) {
1352
1349
ResultTy = Context.getNeverType ();
@@ -1437,13 +1434,11 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
1437
1434
1438
1435
// If this is the name of an LLVM intrinsic, cons up a swift function with a
1439
1436
// type that matches the IR types.
1440
- if (unsigned ID = getLLVMIntrinsicID (OperationName)) {
1437
+ if (llvm::Intrinsic::ID ID = getLLVMIntrinsicID (OperationName)) {
1441
1438
SmallVector<Type, 8 > ArgElts;
1442
1439
Type ResultTy;
1443
- FunctionType::ExtInfo Info;
1444
- if (getSwiftFunctionTypeForIntrinsic (ID, Types, Context, ArgElts, ResultTy,
1445
- Info))
1446
- return getBuiltinFunction (Id, ArgElts, ResultTy, Info);
1440
+ if (getSwiftFunctionTypeForIntrinsic (ID, Types, Context, ArgElts, ResultTy))
1441
+ return getBuiltinFunction (Id, ArgElts, ResultTy);
1447
1442
}
1448
1443
1449
1444
// If this starts with fence, we have special suffixes to handle.
0 commit comments