================
@@ -420,45 +410,66 @@ mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
   return value;
 }
 
-void convertSideEffectForCall(mlir::Operation *callOp, bool isNothrow,
-                              cir::SideEffect sideEffect,
-                              mlir::LLVM::MemoryEffectsAttr &memoryEffect,
-                              bool &noUnwind, bool &willReturn,
-                              bool &noReturn) {
+/// Whether the ABI hands the callee memory through a pointer argument: an
+/// sret slot for an indirect return, or byval / byref for an indirect
+/// argument.  Such a function reaches argument memory no matter what its
+/// source-level attributes say, so `const` and `pure` cannot lower to a
+/// memory effect that excludes it.
+static bool hasABIIndirectMemoryArg(mlir::ArrayAttr argAttrs) {
+  if (!argAttrs)
+    return false;
+  return llvm::any_of(argAttrs, [](mlir::Attribute a) {
+    auto dict = mlir::cast<mlir::DictionaryAttr>(a);
+    return dict.contains(mlir::LLVM::LLVMDialect::getStructRetAttrName()) ||
+           dict.contains(mlir::LLVM::LLVMDialect::getByValAttrName()) ||
+           dict.contains(mlir::LLVM::LLVMDialect::getByRefAttrName());
----------------
andykaylor wrote:

This doesn't seem sufficient to detect indirect cases that don't set either 
`byval` or `byref`, assuming we are going to conform to classic codegen 
handling of `byref`.

https://github.com/llvm/llvm-project/pull/221067
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to