[PATCH] D137083: [ObjCARC] Replace parts of ObjCARCAA with intrinsic attributes

Akira Hatanaka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 13 20:35:16 PST 2022


ahatanak added inline comments.


================
Comment at: llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp:123
-  case ARCInstKind::FusedRetainAutorelease:
-  case ARCInstKind::FusedRetainAutoreleaseRV:
-    // These functions don't access any memory visible to the compiler.
----------------
The comment below doesn't seem correct as I think these functions can indirectly cause a memory location that is visible to the compiler to be modified.

For example, in the code below, method `retain`, which gets called when an object of type `C` is passed to `objc_retain`, modifies `cnt`.

```
@interface C : NSObject {
  @public unsigned cnt;
}
- (instancetype)retain;
@end

@implementation C
- (instancetype)retain {
  ++cnt;
  return [super retain];
}
```

`cnt`  can easily be accessed by the code generated by the compiler. For example:

```
void test(C *c) {
  c->cnt = 0;
}
```

John, does ARC assume that `objc_retain` doesn't access any memory visible to the compiler?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137083/new/

https://reviews.llvm.org/D137083



More information about the llvm-commits mailing list