diff options
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 8767c29..863900c 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -940,8 +940,8 @@ void Function::setOnlyAccessesInaccessibleMemOrArgMem() { } /// Table of string intrinsic names indexed by enum value. -static const char * const IntrinsicNameTable[] = { - "not_intrinsic", +static constexpr const char *const IntrinsicNameTable[] = { + "not_intrinsic", #define GET_INTRINSIC_NAME_TABLE #include "llvm/IR/IntrinsicImpl.inc" #undef GET_INTRINSIC_NAME_TABLE @@ -963,8 +963,9 @@ bool Function::isTargetIntrinsic() const { /// Find the segment of \c IntrinsicNameTable for intrinsics with the same /// target as \c Name, or the generic table if \c Name is not target specific. /// -/// Returns the relevant slice of \c IntrinsicNameTable -static ArrayRef<const char *> findTargetSubtable(StringRef Name) { +/// Returns the relevant slice of \c IntrinsicNameTable and the target name. +static std::pair<ArrayRef<const char *>, StringRef> +findTargetSubtable(StringRef Name) { assert(Name.starts_with("llvm.")); ArrayRef<IntrinsicTargetInfo> Targets(TargetInfos); @@ -976,14 +977,14 @@ static ArrayRef<const char *> findTargetSubtable(StringRef Name) { // We've either found the target or just fall back to the generic set, which // is always first. const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0]; - return ArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count); + return {ArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count), TI.Name}; } -/// This does the actual lookup of an intrinsic ID which -/// matches the given function name. +/// This does the actual lookup of an intrinsic ID which matches the given +/// function name. Intrinsic::ID Function::lookupIntrinsicID(StringRef Name) { - ArrayRef<const char *> NameTable = findTargetSubtable(Name); - int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name); + auto [NameTable, Target] = findTargetSubtable(Name); + int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name, Target); if (Idx == -1) return Intrinsic::not_intrinsic; |