File tree Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ class LLVMContext {
130
130
// / scope names are ordered by increasing synchronization scope IDs.
131
131
void getSyncScopeNames (SmallVectorImpl<StringRef> &SSNs) const ;
132
132
133
+ // / getSyncScopeName - Returns the name of a SyncScope::ID
134
+ // / registered with LLVMContext, if any.
135
+ std::optional<StringRef> getSyncScopeName (SyncScope::ID Id) const ;
136
+
133
137
// / Define the GC for a function
134
138
void setGC (const Function &Fn, std::string GCName);
135
139
Original file line number Diff line number Diff line change @@ -330,6 +330,10 @@ void LLVMContext::getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const {
330
330
pImpl->getSyncScopeNames (SSNs);
331
331
}
332
332
333
+ std::optional<StringRef> LLVMContext::getSyncScopeName (SyncScope::ID Id) const {
334
+ return pImpl->getSyncScopeName (Id);
335
+ }
336
+
333
337
void LLVMContext::setGC (const Function &Fn, std::string GCName) {
334
338
pImpl->GCNames [&Fn] = std::move (GCName);
335
339
}
Original file line number Diff line number Diff line change @@ -244,6 +244,16 @@ void LLVMContextImpl::getSyncScopeNames(
244
244
SSNs[SSE.second ] = SSE.first ();
245
245
}
246
246
247
+ std::optional<StringRef>
248
+ LLVMContextImpl::getSyncScopeName (SyncScope::ID Id) const {
249
+ for (const auto &SSE : SSC) {
250
+ if (SSE.second != Id)
251
+ continue ;
252
+ return SSE.first ();
253
+ }
254
+ return std::nullopt;
255
+ }
256
+
247
257
// / Gets the OptPassGate for this LLVMContextImpl, which defaults to the
248
258
// / singleton OptBisect if not explicitly set.
249
259
OptPassGate &LLVMContextImpl::getOptPassGate () const {
Original file line number Diff line number Diff line change @@ -1665,6 +1665,10 @@ class LLVMContextImpl {
1665
1665
/// scope names are ordered by increasing synchronization scope IDs.
1666
1666
void getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const;
1667
1667
1668
+ /// getSyncScopeName - Returns the name of a SyncScope::ID
1669
+ /// registered with LLVMContext, if any.
1670
+ std::optional<StringRef> getSyncScopeName(SyncScope::ID Id) const;
1671
+
1668
1672
/// Maintain the GC name for each function.
1669
1673
///
1670
1674
/// This saves allocating an additional word in Function for programs which
Original file line number Diff line number Diff line change @@ -16144,11 +16144,8 @@ static bool atomicIgnoresDenormalModeOrFPModeIsFTZ(const AtomicRMWInst *RMW) {
16144
16144
16145
16145
static OptimizationRemark emitAtomicRMWLegalRemark(const AtomicRMWInst *RMW) {
16146
16146
LLVMContext &Ctx = RMW->getContext();
16147
- SmallVector<StringRef> SSNs;
16148
- Ctx.getSyncScopeNames(SSNs);
16149
- StringRef MemScope = SSNs[RMW->getSyncScopeID()].empty()
16150
- ? "system"
16151
- : SSNs[RMW->getSyncScopeID()];
16147
+ StringRef SS = Ctx.getSyncScopeName(RMW->getSyncScopeID()).value_or("");
16148
+ StringRef MemScope = SS.empty() ? StringRef("system") : SS;
16152
16149
16153
16150
return OptimizationRemark(DEBUG_TYPE, "Passed", RMW)
16154
16151
<< "Hardware instruction generated for atomic "
You can’t perform that action at this time.
0 commit comments