diff options
author | gonzalobg <65027571+gonzalobg@users.noreply.github.com> | 2024-09-25 20:13:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 11:13:56 -0700 |
commit | 0f521931b85e6b5f798af357cf32a7ae782a848d (patch) | |
tree | 6061d2028587020f0063b40885f3eee486c157cc /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | c71bfc59ee1cec32d56a82476461e242398f82ca (diff) | |
download | llvm-0f521931b85e6b5f798af357cf32a7ae782a848d.zip llvm-0f521931b85e6b5f798af357cf32a7ae782a848d.tar.gz llvm-0f521931b85e6b5f798af357cf32a7ae782a848d.tar.bz2 |
LLVMContext: add getSyncScopeName() to lookup individual scope name (#109484)
This PR adds a `getSyncScopeString(Id)` API to `LLVMContext` that
returns the `StringRef` for that ID, if any.
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 4f1ef8c..f2c965a 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -244,6 +244,16 @@ void LLVMContextImpl::getSyncScopeNames( SSNs[SSE.second] = SSE.first(); } +std::optional<StringRef> +LLVMContextImpl::getSyncScopeName(SyncScope::ID Id) const { + for (const auto &SSE : SSC) { + if (SSE.second != Id) + continue; + return SSE.first(); + } + return std::nullopt; +} + /// Gets the OptPassGate for this LLVMContextImpl, which defaults to the /// singleton OptBisect if not explicitly set. OptPassGate &LLVMContextImpl::getOptPassGate() const { |