[llvm] Extend MemoryEffects to Support Target-Specific Memory Locations (PR #148650)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 3 03:47:24 PDT 2025
================
@@ -142,6 +142,10 @@ static void addLocAccess(MemoryEffects &ME, const MemoryLocation &Loc,
ME |= MemoryEffects::argMemOnly(MR);
ME |= MemoryEffects(IRMemLocation::ErrnoMem, MR);
ME |= MemoryEffects(IRMemLocation::Other, MR);
+ // Should also set the other Target Memory Locations as MR.
+ // To compares with MemoryEffects::unknown() in addMemoryAttrs
+ ME |= MemoryEffects(IRMemLocation::TargetMem0, MR);
----------------
CarolineConcatto wrote:
The problem I have is that the IR that is failing is a volatile:
```
define dso_local spir_func void @non_convfun() local_unnamed_addr #0 {
entry:
store volatile i32 0, ptr undef, align 4, !tbaa !3
ret void
}
```
In the code in checkFunctionMemoryAccess sets the MemoryEffects if it is volatile:
```
// Volatile operations may access inaccessible memory.
if (I.isVolatile())
ME |= MemoryEffects::inaccessibleMemOnly(MR);
```
And later in addMemoryAttrs it compares with `ME == MemoryEffects::unknown() `which in the past was true because of all memory location in set to ModRef.
Now we don't set all the locations to ModRef(the targets are missing) and because of that the functions starts to identify as memory(readwrite) for the OpenCL test (convergent.cl) Which is not the case.
However is not always that we should setup the volatile target to MR
I believe we can set here because it is where we are setting ErrorMem and also Others. I thought that here is where it makes much sense because it is where we also set Other and ErronoMem.
Or update the test for the
if (ME == MemoryEffects::unknown())
To take into consideration that Target Memory Location will never be tagged in this situation
https://github.com/llvm/llvm-project/pull/148650
More information about the llvm-commits
mailing list