[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 10 02:19:26 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 1. would be the right thing to do, as this location is effectively display only -- the target_mem location is fully covered by the target_memN locations, so it can't really have its own completely independent value.

I think for now it's okay to leave things as-is here, and deal with this when the number of target location becomes > 2.

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


More information about the cfe-commits mailing list