[llvm] LLVMContext: add getSyncScopeName() to lookup individual scope name (PR #109484)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 04:42:06 PDT 2024


================
@@ -16142,11 +16142,8 @@ static bool atomicIgnoresDenormalModeOrFPModeIsFTZ(const AtomicRMWInst *RMW) {
 
 static OptimizationRemark emitAtomicRMWLegalRemark(const AtomicRMWInst *RMW) {
   LLVMContext &Ctx = RMW->getContext();
-  SmallVector<StringRef> SSNs;
-  Ctx.getSyncScopeNames(SSNs);
-  StringRef MemScope = SSNs[RMW->getSyncScopeID()].empty()
-                           ? "system"
-                           : SSNs[RMW->getSyncScopeID()];
+  StringRef SS = Ctx.getSyncScopeName(RMW->getSyncScopeID()).value_or("");
+  StringRef MemScope = SS.empty() ? StringRef("system") : SS;
----------------
gonzalobg wrote:

Right, so this suggestion won't do. 
The current code fills in out of bounds `SyncScope::ID` as `""` (instead of handling that as an error), and then maps `""`  to `"system"` (independently of whether `""` is from out of bounds or from system scope in the IR).

https://github.com/llvm/llvm-project/pull/109484


More information about the llvm-commits mailing list