[clang] [llvm] [mlir] [IR] Make InaccessibleMem a category rather than a location (PR #245318)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 09:47:45 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
@llvm/pr-subscribers-backend-nvptx

@llvm/pr-subscribers-llvm-ir

Author: Serge Pavlov (spavloff)

<details>
<summary>Changes</summary>

The memory location `InaccessibleMem` has been used to express various memory-like restrictions. It is used in many cases where no actual access to memory occurs; the only purpose of this access is to impose restrictions on the control flow. It does not specify a concrete reason why the restrictions are needed, and all operations having such access are subjected to the same restriction. Using more a specific property than the generic access to `InaccessibleMem` can be profitable, and sometimes `InaccessibleMem` undergoes splitting. Previously, `TargetMem` accesses had been separated from `InaccessibleMem` and there is an intention to separate the access to floating-point environment.

At the same time, the notion of `InaccessibleMem` is useful. In many cases, the knowledge that the access cannot alias with any pointer is enough for an algorithm. Considering all locations as a group may simplify algorithms; they continue using functions like `onlyAccessesInaccessibleMem`, although the set of tested locations can vary.

This change reorganizes the interface of MemoryEffects. Instead of `InaccessibleMem`, another location was introduced: `ControlMem`. Functions like `inaccessibleMemOnly` or `onlyAccessesInaccessibleMem` are preserved, but they may test more than one location.

The commit does not add new functionality; most changes are mechanical. However, there are differences with the current behavior.

First, the locations `TargetMem*` are considered part of `InaccessibleMem` locations, and functions like
`onlyAccessesInaccessibleMem` check the relevant access. This behavior differs from the current one, where TargetMem locations are considered as totally independent locations. It is conservatively safe to test `TargetMem` while checking for `InaccessibleMem`; previously the implementation did that.

Printing memory effectshas  also changed. If all `inaccessibleMem` locations have the same access, the dump contains only the `inaccessiblemem` key. The same technique has been used for printing `TargetMem` access.

In some cases, memory effects were initialized by `controlMemOnly` rather than `inaccessibleMemOnly`; this is done when it is clear that target memory, as well as the floating-point environment, do not affect the behavior.

The purpose of this change is to enable intruducing floating-point memory locations, as proposed in
https://github.com/llvm/llvm-project/pull/226826#issuecomment-6634451283.

---

Patch is 270.24 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/245318.diff


93 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+27-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp (+1-1) 
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+44-8) 
- (modified) clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp (+2-2) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/call.c (+2-2) 
- (modified) clang/test/CIR/CodeGen/class.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/new-delete-deactivation.cpp (+6-6) 
- (modified) clang/test/CIR/CodeGen/new-delete-no-exceptions.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/new-delete.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGen/new.cpp (+23-23) 
- (modified) clang/test/CIR/CodeGen/operator-new-noalias.cpp (+4-3) 
- (modified) clang/test/CIR/CodeGen/paren-list-agg-init.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGen/side-effect.cpp (+37-37) 
- (modified) clang/test/CIR/CodeGenBuiltins/builtin-new-delete.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGenCXX/new-array-init.cpp (+19-19) 
- (modified) clang/test/CIR/IR/call.cir (+10-10) 
- (modified) clang/test/CIR/Lowering/memory-effects.cir (+8-8) 
- (modified) clang/test/CIR/Transforms/abi-lowering/memory-effects-argmem-indirect.cir (+3-3) 
- (modified) clang/test/CIR/Transforms/abi-lowering/memory-effects-argmem.cir (+12-12) 
- (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-indirect-variadic.cir (+3-3) 
- (modified) clang/test/CIR/Transforms/flatten-preserve-attrs.cir (+8-8) 
- (modified) clang/test/CIR/Transforms/idiom-recognizer.cpp (+1-1) 
- (modified) clang/test/CodeGen/sanitize-metadata-nosanitize.c (+9-9) 
- (modified) clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp (+6-6) 
- (modified) clang/test/CodeGenCXX/new.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/new_hot_cold.cpp (+8-8) 
- (modified) clang/test/CodeGenCXX/operator-new.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/threadlocal_address.cpp (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+3) 
- (modified) llvm/include/llvm/AsmParser/LLToken.h (+1) 
- (modified) llvm/include/llvm/IR/Function.h (-10) 
- (modified) llvm/include/llvm/IR/InstrTypes.h (-2) 
- (modified) llvm/include/llvm/IR/Intrinsics.td (+15-5) 
- (modified) llvm/include/llvm/IR/IntrinsicsAArch64.td (+2-2) 
- (modified) llvm/include/llvm/IR/IntrinsicsNVVM.td (+1-1) 
- (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+11-11) 
- (modified) llvm/include/llvm/IR/RuntimeLibcallsImpl.td (+7-7) 
- (modified) llvm/include/llvm/Support/ModRef.h (+64-17) 
- (modified) llvm/lib/Analysis/AliasAnalysis.cpp (+7-9) 
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+3-4) 
- (modified) llvm/lib/AsmParser/LLLexer.cpp (+1) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+10-3) 
- (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+16-16) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+1-1) 
- (modified) llvm/lib/IR/Attributes.cpp (+36-10) 
- (modified) llvm/lib/IR/Function.cpp (-19) 
- (modified) llvm/lib/IR/Instruction.cpp (+1-1) 
- (modified) llvm/lib/IR/Instructions.cpp (+1-8) 
- (modified) llvm/lib/Support/ModRef.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-3) 
- (modified) llvm/test/Assembler/memory-attribute-errors.ll (+3-3) 
- (modified) llvm/test/Assembler/memory-attribute.ll (+2-2) 
- (modified) llvm/test/Bitcode/compatibility-3.6.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-3.7.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-3.8.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-3.9.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-4.0.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-5.0.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility-6.0.ll (+1-1) 
- (modified) llvm/test/Bitcode/compatibility.ll (+1-1) 
- (modified) llvm/test/Bitcode/memory-attribute-upgrade.ll (+2-2) 
- (modified) llvm/test/Bitcode/target-memory-attribute.ll (+2-2) 
- (modified) llvm/test/Instrumentation/AddressSanitizer/remove-memory-effects.ll (+2-2) 
- (modified) llvm/test/Instrumentation/HWAddressSanitizer/mem-attr.ll (+2-2) 
- (modified) llvm/test/TableGen/target-mem-intrinsic-attrs.td (+13-13) 
- (modified) llvm/test/Transforms/EarlyCSE/target-memory.ll (+7-7) 
- (modified) llvm/test/Transforms/FunctionAttrs/argmemonly.ll (+11-11) 
- (modified) llvm/test/Transforms/FunctionAttrs/atomic.ll (+2-2) 
- (modified) llvm/test/Transforms/FunctionAttrs/initializes.ll (+6-6) 
- (modified) llvm/test/Transforms/FunctionAttrs/nocapture.ll (+19-19) 
- (modified) llvm/test/Transforms/FunctionAttrs/nofpclass.ll (+2-2) 
- (modified) llvm/test/Transforms/FunctionAttrs/nosync.ll (+3-3) 
- (modified) llvm/test/Transforms/FunctionAttrs/read-write-scc.ll (+2-2) 
- (modified) llvm/test/Transforms/FunctionAttrs/readattrs.ll (+2-2) 
- (modified) llvm/test/Transforms/FunctionAttrs/writeonly.ll (+3-3) 
- (modified) llvm/test/Transforms/GlobalOpt/disable-globals-aa.ll (+4-4) 
- (modified) llvm/test/Transforms/InferFunctionAttrs/annotate.ll (+10-10) 
- (modified) llvm/test/Transforms/InferFunctionAttrs/enable-builtin.ll (+1-1) 
- (modified) llvm/test/Transforms/InferFunctionAttrs/norecurse_debug.ll (+1-1) 
- (modified) llvm/test/Transforms/LowerTypeTests/cfi-nounwind-direct-call.ll (+1-1) 
- (modified) llvm/test/Transforms/SCCP/ipscp-drop-argmemonly.ll (+6-10) 
- (modified) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll (+3-3) 
- (modified) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll (+9-9) 
- (modified) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/windows.ll (+12-12) 
- (modified) llvm/unittests/Support/ModRefTest.cpp (+28-27) 
- (modified) llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp (+10-7) 
- (modified) llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp (+1-1) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp (+1-1) 
- (modified) mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp (+2-2) 
- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+7-7) 
- (modified) mlir/lib/Target/LLVMIR/ModuleTranslation.cpp (+3-3) 


``````````diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 33360b773093dd..82816365c869f0 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -2434,7 +2434,7 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
       parameters, including locations with no class of their own such as
       globals and captured pointers.
     - `arg_mem`: accesses based on the function's pointer arguments.
-    - `inaccessible_mem`: accesses to memory the current module cannot reach,
+    - `control_mem`: accesses to memory the current module cannot reach,
       often used to model the control dependencies of intrinsics.
     - `errno_mem`: accesses to the `errno` variable.
     - `target_mem0`, `target_mem1`: target-specific state.
@@ -2449,7 +2449,7 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
     Example:
     ```
     #cir.memory_effects<other = read, arg_mem = readwrite,
-                        inaccessible_mem = none, errno_mem = none,
+                        control_mem = none, errno_mem = none,
                         target_mem0 = none, target_mem1 = none>
     ```
 
@@ -2463,7 +2463,7 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
   }];
 
   let parameters = (ins "ModRefInfo":$other, "ModRefInfo":$arg_mem,
-                        "ModRefInfo":$inaccessible_mem,
+                        "ModRefInfo":$control_mem,
                         "ModRefInfo":$errno_mem, "ModRefInfo":$target_mem0,
                         "ModRefInfo":$target_mem1);
 
@@ -2489,6 +2489,10 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
     static MemoryEffectsAttr argMemOnly(::mlir::MLIRContext *ctx,
                                         ModRefInfo mr = ModRefInfo::ModRef);
 
+    /// Create MemoryEffectsAttr that can only access control memory.
+    static MemoryEffectsAttr controlMemOnly(::mlir::MLIRContext *ctx,
+                                            ModRefInfo mr = ModRefInfo::ModRef);
+
     /// Create MemoryEffectsAttr that can only access inaccessible memory.
     static MemoryEffectsAttr
     inaccessibleMemOnly(::mlir::MLIRContext *ctx,
@@ -2508,6 +2512,12 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
     inaccessibleOrArgMemOnly(::mlir::MLIRContext *ctx,
                              ModRefInfo mr = ModRefInfo::ModRef);
 
+    /// Create MemoryEffectsAttr that can only access control or argument
+    /// memory.
+    static MemoryEffectsAttr
+    controlOrArgMemOnly(::mlir::MLIRContext *ctx,
+                        ModRefInfo mr = ModRefInfo::ModRef);
+
     /// Create MemoryEffectsAttr that can only access inaccessible or errno
     /// memory.
     static MemoryEffectsAttr inaccessibleOrErrnoMemOnly(
@@ -2515,6 +2525,13 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
         ModRefInfo inaccessibleMr = ModRefInfo::ModRef,
         ModRefInfo errnoMr = ModRefInfo::ModRef);
 
+    /// Create MemoryEffectsAttr that can only access control or errno
+    /// memory.
+    static MemoryEffectsAttr controlOrErrnoMemOnly(
+        ::mlir::MLIRContext *ctx,
+        ModRefInfo controlMr = ModRefInfo::ModRef,
+        ModRefInfo errnoMr = ModRefInfo::ModRef);
+
     /// Create MemoryEffectsAttr that can only access inaccessible, argument or
     /// errno memory.
     static MemoryEffectsAttr inaccessibleOrArgOrErrnoMemOnly(
@@ -2522,6 +2539,13 @@ def CIR_MemoryEffectsAttr : CIR_Attr<"MemoryEffects", "memory_effects"> {
         ModRefInfo inaccessibleOrArgMr = ModRefInfo::ModRef,
         ModRefInfo errnoMr = ModRefInfo::ModRef);
 
+    /// Create MemoryEffectsAttr that can only access control, argument or
+    /// errno memory.
+    static MemoryEffectsAttr controlOrArgOrErrnoMemOnly(
+        ::mlir::MLIRContext *ctx,
+        ModRefInfo controlOrArgMr = ModRefInfo::ModRef,
+        ModRefInfo errnoMr = ModRefInfo::ModRef);
+
     /// Create MemoryEffectsAttr that can only access argument or errno memory.
     static MemoryEffectsAttr
     argumentOrErrnoMemOnly(::mlir::MLIRContext *ctx,
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
index d19784a491e1f0..453d6da857db9b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
@@ -775,7 +775,7 @@ static RValue emitNewDeleteCall(CIRGenFunction &cgf,
       // FIXME: inaccessiblemem could cause issues if LTO makes the
       // previously inaccessible memory accessible after linking.
       callOrTryCall.setMemoryEffectsAttr(
-          cir::MemoryEffectsAttr::inaccessibleOrErrnoMemOnly(
+          cir::MemoryEffectsAttr::controlOrErrnoMemOnly(
               callOrTryCall->getContext(), cir::ModRefInfo::ModRef,
               cir::ModRefInfo::Mod));
     }
diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
index ab4cbaf5bd4994..7c243cf64a3f98 100644
--- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
@@ -468,7 +468,7 @@ MemoryEffectsAttr MemoryEffectsAttr::writeOnly(MLIRContext *ctx) {
 MemoryEffectsAttr MemoryEffectsAttr::argMemOnly(MLIRContext *ctx,
                                                 ModRefInfo mr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef, /*arg_mem=*/mr,
-             /*inaccessible_mem=*/ModRefInfo::NoModRef,
+             /*control_mem=*/ModRefInfo::NoModRef,
              /*errno_mem=*/ModRefInfo::NoModRef,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
@@ -477,7 +477,16 @@ MemoryEffectsAttr MemoryEffectsAttr::argMemOnly(MLIRContext *ctx,
 MemoryEffectsAttr MemoryEffectsAttr::inaccessibleMemOnly(MLIRContext *ctx,
                                                          ModRefInfo mr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef,
-             /*arg_mem=*/ModRefInfo::NoModRef, /*inaccessible_mem=*/mr,
+             /*arg_mem=*/ModRefInfo::NoModRef, /*control_mem=*/mr,
+             /*errno_mem=*/ModRefInfo::NoModRef,
+             /*target_mem0=*/mr,
+             /*target_mem1=*/mr);
+}
+
+MemoryEffectsAttr MemoryEffectsAttr::controlMemOnly(MLIRContext *ctx,
+                                                    ModRefInfo mr) {
+  return get(ctx, /*other=*/ModRefInfo::NoModRef,
+             /*arg_mem=*/ModRefInfo::NoModRef, /*control_mem=*/mr,
              /*errno_mem=*/ModRefInfo::NoModRef,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
@@ -487,7 +496,7 @@ MemoryEffectsAttr MemoryEffectsAttr::errnoMemOnly(MLIRContext *ctx,
                                                   ModRefInfo mr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef,
              /*arg_mem=*/ModRefInfo::NoModRef,
-             /*inaccessible_mem=*/ModRefInfo::NoModRef, /*errno_mem=*/mr,
+             /*control_mem=*/ModRefInfo::NoModRef, /*errno_mem=*/mr,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
 }
@@ -495,7 +504,7 @@ MemoryEffectsAttr MemoryEffectsAttr::errnoMemOnly(MLIRContext *ctx,
 MemoryEffectsAttr MemoryEffectsAttr::otherMemOnly(MLIRContext *ctx,
                                                   ModRefInfo mr) {
   return get(ctx, /*other=*/mr, /*arg_mem=*/ModRefInfo::NoModRef,
-             /*inaccessible_mem=*/ModRefInfo::NoModRef,
+             /*control_mem=*/ModRefInfo::NoModRef,
              /*errno_mem=*/ModRefInfo::NoModRef,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
@@ -504,7 +513,15 @@ MemoryEffectsAttr MemoryEffectsAttr::otherMemOnly(MLIRContext *ctx,
 MemoryEffectsAttr MemoryEffectsAttr::inaccessibleOrArgMemOnly(MLIRContext *ctx,
                                                               ModRefInfo mr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef, /*arg_mem=*/mr,
-             /*inaccessible_mem=*/mr, /*errno_mem=*/ModRefInfo::NoModRef,
+             /*control_mem=*/mr, /*errno_mem=*/ModRefInfo::NoModRef,
+             /*target_mem0=*/mr,
+             /*target_mem1=*/mr);
+}
+
+MemoryEffectsAttr MemoryEffectsAttr::controlOrArgMemOnly(MLIRContext *ctx,
+                                                         ModRefInfo mr) {
+  return get(ctx, /*other=*/ModRefInfo::NoModRef, /*arg_mem=*/mr,
+             /*control_mem=*/mr, /*errno_mem=*/ModRefInfo::NoModRef,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
 }
@@ -513,7 +530,17 @@ MemoryEffectsAttr MemoryEffectsAttr::inaccessibleOrErrnoMemOnly(
     MLIRContext *ctx, ModRefInfo inaccessibleMr, ModRefInfo errnoMr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef,
              /*arg_mem=*/ModRefInfo::NoModRef,
-             /*inaccessible_mem=*/inaccessibleMr, /*errno_mem=*/errnoMr,
+             /*control_mem=*/inaccessibleMr, /*errno_mem=*/errnoMr,
+             /*target_mem0=*/inaccessibleMr,
+             /*target_mem1=*/inaccessibleMr);
+}
+
+MemoryEffectsAttr MemoryEffectsAttr::controlOrErrnoMemOnly(MLIRContext *ctx,
+                                                           ModRefInfo controlMr,
+                                                           ModRefInfo errnoMr) {
+  return get(ctx, /*other=*/ModRefInfo::NoModRef,
+             /*arg_mem=*/ModRefInfo::NoModRef,
+             /*control_mem=*/controlMr, /*errno_mem=*/errnoMr,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
 }
@@ -522,7 +549,16 @@ MemoryEffectsAttr MemoryEffectsAttr::inaccessibleOrArgOrErrnoMemOnly(
     MLIRContext *ctx, ModRefInfo inaccessibleOrArgMr, ModRefInfo errnoMr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef,
              /*arg_mem=*/inaccessibleOrArgMr,
-             /*inaccessible_mem=*/inaccessibleOrArgMr, /*errno_mem=*/errnoMr,
+             /*control_mem=*/inaccessibleOrArgMr, /*errno_mem=*/errnoMr,
+             /*target_mem0=*/inaccessibleOrArgMr,
+             /*target_mem1=*/inaccessibleOrArgMr);
+}
+
+MemoryEffectsAttr MemoryEffectsAttr::controlOrArgOrErrnoMemOnly(
+    MLIRContext *ctx, ModRefInfo inaccessibleOrArgMr, ModRefInfo errnoMr) {
+  return get(ctx, /*other=*/ModRefInfo::NoModRef,
+             /*arg_mem=*/inaccessibleOrArgMr,
+             /*control_mem=*/inaccessibleOrArgMr, /*errno_mem=*/errnoMr,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
 }
@@ -531,7 +567,7 @@ MemoryEffectsAttr
 MemoryEffectsAttr::argumentOrErrnoMemOnly(MLIRContext *ctx, ModRefInfo argMr,
                                           ModRefInfo errnoMr) {
   return get(ctx, /*other=*/ModRefInfo::NoModRef, /*arg_mem=*/argMr,
-             /*inaccessible_mem=*/ModRefInfo::NoModRef, /*errno_mem=*/errnoMr,
+             /*control_mem=*/ModRefInfo::NoModRef, /*errno_mem=*/errnoMr,
              /*target_mem0=*/ModRefInfo::NoModRef,
              /*target_mem1=*/ModRefInfo::NoModRef);
 }
diff --git a/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp b/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
index 2ccf798e5fa3f4..b7a4c68db82a78 100644
--- a/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
@@ -90,8 +90,8 @@ template <typename OpTy> static void widenForArgMemory(OpTy op) {
     return;
   op.setMemoryEffectsAttr(cir::MemoryEffectsAttr::get(
       effects.getContext(), effects.getOther(), cir::ModRefInfo::ModRef,
-      effects.getInaccessibleMem(), effects.getErrnoMem(),
-      effects.getTargetMem0(), effects.getTargetMem1()));
+      effects.getControlMem(), effects.getErrnoMem(), effects.getTargetMem0(),
+      effects.getTargetMem1()));
 }
 
 #ifndef NDEBUG
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index b470b07efddd15..f9beaee477a254 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -572,7 +572,7 @@ convertMemoryEffects(mlir::MLIRContext *ctx, cir::MemoryEffectsAttr effects) {
   return mlir::LLVM::MemoryEffectsAttr::get(
       ctx, convertModRefInfo(effects.getOther()),
       convertModRefInfo(effects.getArgMem()),
-      convertModRefInfo(effects.getInaccessibleMem()),
+      convertModRefInfo(effects.getControlMem()),
       convertModRefInfo(effects.getErrnoMem()),
       convertModRefInfo(effects.getTargetMem0()),
       convertModRefInfo(effects.getTargetMem1()));
diff --git a/clang/test/CIR/CodeGen/call.c b/clang/test/CIR/CodeGen/call.c
index dfc58315a0cdc2..2fc11f57d7380b 100644
--- a/clang/test/CIR/CodeGen/call.c
+++ b/clang/test/CIR/CodeGen/call.c
@@ -138,9 +138,9 @@ int f12(void) {
 
 // CIR-LABEL: cir.func{{.*}} @f12() -> !s32i{{.*}} {
 // CIR:         %[[A:.+]] = cir.const #cir.int<1> : !s32i
-// CIR-NEXT:    %{{.+}} = cir.call @f10(%[[A]]) nounwind willreturn {memory_effects = #cir.memory_effects<other = read, arg_mem = read, inaccessible_mem = read, errno_mem = read, target_mem0 = read, target_mem1 = read>} : (!s32i {llvm.noundef}) -> !s32i
+// CIR-NEXT:    %{{.+}} = cir.call @f10(%[[A]]) nounwind willreturn {memory_effects = #cir.memory_effects<other = read, arg_mem = read, control_mem = read, errno_mem = read, target_mem0 = read, target_mem1 = read>} : (!s32i {llvm.noundef}) -> !s32i
 // CIR-NEXT:    %[[B:.+]] = cir.const #cir.int<2> : !s32i
-// CIR-NEXT:    %{{.+}} = cir.call @f11(%[[B]]) nounwind willreturn {memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = none, errno_mem = none, target_mem0 = none, target_mem1 = none>} : (!s32i {llvm.noundef}) -> !s32i
+// CIR-NEXT:    %{{.+}} = cir.call @f11(%[[B]]) nounwind willreturn {memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = none, errno_mem = none, target_mem0 = none, target_mem1 = none>} : (!s32i {llvm.noundef}) -> !s32i
 
 // LLVM-LABEL: define{{.*}} i32 @f12(){{.*}}
 // LLVM:         %{{.+}} = call i32 @f10(i32 noundef 1) #[[ATTR0:.+]]
diff --git a/clang/test/CIR/CodeGen/class.cpp b/clang/test/CIR/CodeGen/class.cpp
index 282d9ef0b80166..3bbb2d8b656ad3 100644
--- a/clang/test/CIR/CodeGen/class.cpp
+++ b/clang/test/CIR/CodeGen/class.cpp
@@ -181,7 +181,7 @@ void fam_3() {
 // CIR: cir.func{{.*}}@_Z5fam_3v
 // CIR: %[[A:.*]] = cir.alloca "a" align(8) init : !cir.ptr<!cir.ptr<!rec_JustFam>>
 // CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !u64i
-// CIR: %[[NEW:.*]] = cir.call @_Znwm(%[[ZERO]]) {allocsize = array<i32: 0>, builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR: %[[NEW:.*]] = cir.call @_Znwm(%[[ZERO]]) {allocsize = array<i32: 0>, builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR: %[[NEW_TO_A:.*]] = cir.cast bitcast %[[NEW]] : !cir.ptr<!void> -> !cir.ptr<!rec_JustFam>
 // CIR: cir.store align(8) %[[NEW_TO_A]], %[[A]] : !cir.ptr<!rec_JustFam>, !cir.ptr<!cir.ptr<!rec_JustFam>>
 // CIR: %[[LOAD_A:.*]] = cir.load align(8) %[[A]] : !cir.ptr<!cir.ptr<!rec_JustFam>>, !cir.ptr<!rec_JustFam>
diff --git a/clang/test/CIR/CodeGen/new-delete-deactivation.cpp b/clang/test/CIR/CodeGen/new-delete-deactivation.cpp
index a2f70507946d22..13eb9d5c38e221 100644
--- a/clang/test/CIR/CodeGen/new-delete-deactivation.cpp
+++ b/clang/test/CIR/CodeGen/new-delete-deactivation.cpp
@@ -26,7 +26,7 @@ A *deact_simple() { return new A(makeB()); }
 // CIR:   %[[NEW_RESULT:.*]] = cir.alloca "__new_result" {{.*}} : !cir.ptr<!cir.ptr<!rec_A>>
 // CIR:   %[[TMP:.*]] = cir.alloca "ref.tmp0" {{.*}} : !cir.ptr<!rec_B>
 // CIR:   %[[ACTIVE:.*]] = cir.alloca "cleanup.isactive" {{.*}} : !cir.ptr<!cir.bool>
-// CIR:   %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR:   %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR:   cir.cleanup.scope {
 // CIR:     %[[TRUE:.*]] = cir.const #true
 // CIR:     cir.store %[[TRUE]], %[[ACTIVE]] : !cir.bool, !cir.ptr<!cir.bool>
@@ -106,7 +106,7 @@ A *deact_if(bool cond) {
 // CIR-LABEL: cir.func {{.*}} @_Z8deact_ifb
 // CIR:   cir.if {{.*}} {
 // CIR:     %[[ACTIVE:.*]] = cir.alloca "cleanup.isactive" {{.*}} : !cir.ptr<!cir.bool>
-// CIR:     %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR:     %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR:     cir.cleanup.scope {
 // CIR:       %[[TRUE:.*]] = cir.const #true
 // CIR:       cir.store %[[TRUE]], %[[ACTIVE]] : !cir.bool, !cir.ptr<!cir.bool>
@@ -162,7 +162,7 @@ A *deact_ternary(bool cond) { return (new A(makeB()), cond) ? nullptr : nullptr;
 
 // CIR-LABEL: cir.func {{.*}} @_Z13deact_ternaryb
 // CIR:   %[[ACTIVE:.*]] = cir.alloca "cleanup.isactive" {{.*}} : !cir.ptr<!cir.bool>
-// CIR:   %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR:   %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR:   cir.cleanup.scope {
 // CIR:     %[[TRUE:.*]] = cir.const #true
 // CIR:     cir.store %[[TRUE]], %[[ACTIVE]] : !cir.bool, !cir.ptr<!cir.bool>
@@ -219,7 +219,7 @@ A *deact_while_cond(int n) {
 // CIR-LABEL: cir.func {{.*}} @_Z16deact_while_condi
 // CIR:   %[[ACTIVE:.*]] = cir.alloca "cleanup.isactive" {{.*}} : !cir.ptr<!cir.bool>
 // CIR:   cir.while {
-// CIR:     %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR:     %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR:     cir.cleanup.scope {
 // CIR:       %[[TRUE:.*]] = cir.const #true
 // CIR:       cir.store %[[TRUE]], %[[ACTIVE]] : !cir.bool, !cir.ptr<!cir.bool>
@@ -299,7 +299,7 @@ A *deact_switch(int kind) {
 // CIR:   %[[ACTIVE:.*]] = cir.alloca "cleanup.isactive" {{.*}} : !cir.ptr<!cir.bool>
 // CIR:   cir.switch({{.*}}) {
 // CIR:     cir.case(equal, [#cir.int<1> : !s32i]) {
-// CIR:       %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, inaccessible_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
+// CIR:       %[[PTR:.*]] = cir.call @_Znwm({{.*}}) {{{.*}}builtin, memory_effects = #cir.memory_effects<other = none, arg_mem = none, control_mem = readwrite, errno_mem = write, target_mem0 = none, target_mem1 = none>}
 // CIR:       cir.cleanup.scope {
 // CIR:         %[[TRUE:.*]] = cir.const #true
 // CIR:         cir.store %[[TRUE]], %[[ACTIVE]] : !cir.bool, !cir.ptr<!cir.bool>
@@ -358,7 +358,7 @@ A *deact_switch(int kind) {
 // OGCG: [[DO_DELETE]]:
 // OGCG:   call void @_ZdlPv(ptr allocptr %[[PTR]])
 
-// LLVM-DAG: attributes #[[ATTR_BUILTIN_NEW]] = {{{.*}}builtin{{.*}}memory(inaccessiblemem: readwrite, errnomem: write){{.*}}}
+// LLVM-DAG: attributes #[[ATTR_BUILTIN_NEW]] = {{{.*}}builtin{{.*}}memory(errnomem: write, controlmem: readwrite){{.*}}}
 // LLVM-DAG: attributes #[[ATTR_BUILTIN_DEL]] = {{{.*}}builtin{{.*}}}
 // LLVM-DAG: attributes #[[ATTR_NOUNWIND]] = {{{.*}}nounwind{{.*}}...
[truncated]

``````````

</details>


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


More information about the cfe-commits mailing list