aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
diff options
context:
space:
mode:
authorRahul Joshi <rjoshi@nvidia.com>2024-09-25 12:01:43 -0700
committerGitHub <noreply@github.com>2024-09-25 12:01:43 -0700
commit6786928c4fe1f9daf720d3b604987de2b013e70b (patch)
tree6019e52986dad7fa3b6440574413ab42db1df05d /llvm/lib/IR/IntrinsicInst.cpp
parent2f43e65955565f92d3103b4bd57f17d02385d0e3 (diff)
downloadllvm-6786928c4fe1f9daf720d3b604987de2b013e70b.zip
llvm-6786928c4fe1f9daf720d3b604987de2b013e70b.tar.gz
llvm-6786928c4fe1f9daf720d3b604987de2b013e70b.tar.bz2
[Core] Skip over target name in intrinsic name lookup (#109971)
When searching for an intrinsic name in a target specific slice of the intrinsic name table, skip over the target prefix. For such cases, currently the first loop iteration in `lookupLLVMIntrinsicByName` does nothing (i.e., `Low` and `High` stay unchanged and it does not shrink down the search window), so we can skip this useless first iteration by skipping over the target prefix.
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r--llvm/lib/IR/IntrinsicInst.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 7ed82c2..5654a3a 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -237,8 +237,10 @@ void DbgAssignIntrinsic::setValue(Value *V) {
}
int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
- StringRef Name) {
+ StringRef Name,
+ StringRef Target) {
assert(Name.starts_with("llvm.") && "Unexpected intrinsic prefix");
+ assert(Name.drop_front(5).starts_with(Target) && "Unexpected target");
// Do successive binary searches of the dotted name components. For
// "llvm.gc.experimental.statepoint.p1i8.p1i32", we will find the range of
@@ -248,6 +250,9 @@ int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
// identical. By using strncmp we consider names with differing suffixes to
// be part of the equal range.
size_t CmpEnd = 4; // Skip the "llvm" component.
+ if (!Target.empty())
+ CmpEnd += 1 + Target.size(); // skip the .target component.
+
const char *const *Low = NameTable.begin();
const char *const *High = NameTable.end();
const char *const *LastLow = Low;