[llvm] [SimplifyCFG] Use isWritableObject() API (PR #110127)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 08:20:42 PDT 2024


================
@@ -892,7 +892,10 @@ bool llvm::isWritableObject(const Value *Object,
     return true;
 
   if (auto *A = dyn_cast<Argument>(Object)) {
-    if (A->hasAttribute(Attribute::Writable)) {
+    // Also require noalias, otherwise writability at function entry cannot be
+    // generalized to writability at other program points, even if the pointer
+    // does not escape.
+    if (A->hasAttribute(Attribute::Writable) && A->hasNoAliasAttr()) {
----------------
nikic wrote:

Part of the API contract for this function is:

> At later points, this is only the case if the pointer can not escape to a different thread.

Without noalias, this is not true.

Besides, it has "object" in the name, which in the context of AA refers to identified objects. A pointer argument is only an identified object if it's either byval or noalias.

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


More information about the llvm-commits mailing list