[clang] [llvm] [mlir] [LLVM] Improve IR parsing and printing for target memory locations (PR #176968)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 08:02:46 PST 2026


================
@@ -653,15 +653,26 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
       OS << getModRefStr(OtherMR);
     }
 
+    bool TargetPrintedForAll = false;
     for (auto Loc : MemoryEffects::locations()) {
       ModRefInfo MR = ME.getModRef(Loc);
       if (MR == OtherMR)
         continue;
 
-      if (!First)
+      if (!First && !TargetPrintedForAll)
         OS << ", ";
       First = false;
 
+      if (ME.isTargetMemLoc(Loc) && ME.isTargetMemLocSameForAll()) {
----------------
nikic wrote:

I think the behavior that we'd actually want here is to take the most common value for target_mem and then print separately the ones that differ. Though with currently only 2 target memory locations this makes no difference. It would only become relevant if there are more (e.g. if we expand to 8 target memory locations and only 1 of them differs).

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


More information about the cfe-commits mailing list