Skip to content

[NFC] Eliminate use of lookupLLVMIntrinsicByName in Coroutines #114851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Nov 4, 2024

Eliminate use of lookupLLVMIntrinsicByName from Coroutines in preparation of changing it to support a different form of intrinsic name table generated by intrinsic emitter.

Also eliminate call to isCoroutineIntrinsicName from declaresAnyIntrinsic as the list of names traversed is the same list which isCoroutineIntrinsicName checks.

Eliminate use of `lookupLLVMIntrinsicByName` from Coroutines in
preparation of changing it to support a different form of intrinsic
name table generated by intrinsic emitter.

Also eliminate call to `isCoroutineIntrinsicName` from
`declaresAnyIntrinsic` as the list of names traversed is the same
list which `isCoroutineIntrinsicName` checks.
@jurahul jurahul force-pushed the fixup_isCoroutineIntrinsicName branch from ec725fd to 5c80973 Compare November 4, 2024 23:16
@jurahul jurahul marked this pull request as ready for review November 5, 2024 15:03
@jurahul jurahul requested a review from arsenm November 5, 2024 15:04
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-coroutines

Author: Rahul Joshi (jurahul)

Changes

Eliminate use of lookupLLVMIntrinsicByName from Coroutines in preparation of changing it to support a different form of intrinsic name table generated by intrinsic emitter.

Also eliminate call to isCoroutineIntrinsicName from declaresAnyIntrinsic as the list of names traversed is the same list which isCoroutineIntrinsicName checks.


Full diff: https://github.com/llvm/llvm-project/pull/114851.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Coroutines/Coroutines.cpp (+1-3)
diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
index 45b9767657c66a..331a9c942ae600 100644
--- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -100,8 +100,7 @@ static const char *const CoroIntrinsics[] = {
 
 #ifndef NDEBUG
 static bool isCoroutineIntrinsicName(StringRef Name) {
-  return Intrinsic::lookupLLVMIntrinsicByName(CoroIntrinsics, Name, "coro") !=
-         -1;
+  return llvm::binary_search(CoroIntrinsics, Name);
 }
 #endif
 
@@ -111,7 +110,6 @@ bool coro::isSuspendBlock(BasicBlock *BB) {
 
 bool coro::declaresAnyIntrinsic(const Module &M) {
   for (StringRef Name : CoroIntrinsics) {
-    assert(isCoroutineIntrinsicName(Name) && "not a coroutine intrinsic");
     if (M.getNamedValue(Name))
       return true;
   }

@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Rahul Joshi (jurahul)

Changes

Eliminate use of lookupLLVMIntrinsicByName from Coroutines in preparation of changing it to support a different form of intrinsic name table generated by intrinsic emitter.

Also eliminate call to isCoroutineIntrinsicName from declaresAnyIntrinsic as the list of names traversed is the same list which isCoroutineIntrinsicName checks.


Full diff: https://github.com/llvm/llvm-project/pull/114851.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Coroutines/Coroutines.cpp (+1-3)
diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
index 45b9767657c66a..331a9c942ae600 100644
--- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -100,8 +100,7 @@ static const char *const CoroIntrinsics[] = {
 
 #ifndef NDEBUG
 static bool isCoroutineIntrinsicName(StringRef Name) {
-  return Intrinsic::lookupLLVMIntrinsicByName(CoroIntrinsics, Name, "coro") !=
-         -1;
+  return llvm::binary_search(CoroIntrinsics, Name);
 }
 #endif
 
@@ -111,7 +110,6 @@ bool coro::isSuspendBlock(BasicBlock *BB) {
 
 bool coro::declaresAnyIntrinsic(const Module &M) {
   for (StringRef Name : CoroIntrinsics) {
-    assert(isCoroutineIntrinsicName(Name) && "not a coroutine intrinsic");
     if (M.getNamedValue(Name))
       return true;
   }

@jurahul jurahul requested a review from TylerNowicki November 5, 2024 15:04
@jurahul
Copy link
Contributor Author

jurahul commented Nov 6, 2024

Thanks @ChuanqiXu9. Will wait for a couple of days to give other reviewers a chance to review.

@jurahul jurahul merged commit 8888352 into llvm:main Nov 12, 2024
12 checks passed
@jurahul jurahul deleted the fixup_isCoroutineIntrinsicName branch November 12, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants