diff options
author | Andrzej Warzyński <andrzej.warzynski@arm.com> | 2025-04-02 21:26:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-02 21:26:41 +0100 |
commit | 2bee24632f38699f1af8fdf4daa5b28053c7ae5f (patch) | |
tree | 58de41c1dbe23a60fc42bea6d14966f58f81aa67 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | df9e5ae5b40c4d245d904a2565e46f5b7ab9c7c8 (diff) | |
download | llvm-2bee24632f38699f1af8fdf4daa5b28053c7ae5f.zip llvm-2bee24632f38699f1af8fdf4daa5b28053c7ae5f.tar.gz llvm-2bee24632f38699f1af8fdf4daa5b28053c7ae5f.tar.bz2 |
[mlir][bugfix] Fix erroneous condition in `getEffectsOnResource` (#133638)
This patch corrects an invalid condition in `getEffectsOnResource` used
to identify relevant "resources":
```cpp
return it.getResource() != resource;
```
The current implementation assumes that only one instance of each
resource will exist, so comparing raw pointers is both safe and
sufficient. This assumption stems from constructs like:
```cpp
static DerivedResource *get() {
static DerivedResource instance;
return &instance;
}
```
i.e., resource instances returned via static singleton methods.
However, as discussed in
* https://github.com/llvm/llvm-project/issues/129216,
this assumption breaks in practice — notably on macOS (Apple Silicon)
when built with:
* `-DBUILD_SHARED_LIBS=On`.
In such cases, multiple instances of the same logical resource may exist
across shared library boundaries, leading to incorrect behavior and
causing failures in tests like:
* test/Dialect/Transform/check-use-after-free.mlir
This patch replaces the pointer comparison with a comparison based on
resource identity:
```cpp
return it.getResource()->getResourceID() != resource->getResourceID();
```
This approach aligns better with the intent of `getEffectsOnResource`,
which is to:
```cpp
/// Collect all of the effect instances that operate on the provided
/// resource (...)
```
Fixes #129216
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions