Bruno De Fraine 656bf13004
[AST] Don't merge memory locations in AliasSetTracker (#65731)
This changes the AliasSetTracker to track memory locations instead of
pointers in its alias sets. The motivation for this is outlined in an RFC
posted on LLVM discourse:
https://discourse.llvm.org/t/rfc-dont-merge-memory-locations-in-aliassettracker/73336

In the data structures of the AST implementation, I made the choice to
replace the linked list of `PointerRec` entries (that had to go anyway)
with a simple flat vector of `MemoryLocation` objects, but for the
`AliasSet` objects referenced from a lookup table, I retained the
mechanism of a linked list, reference counting, forwarding, etc. The
data structures could be revised in a follow-up change.
2024-01-17 15:59:13 +01:00

49 lines
2.0 KiB
LLVM

; RUN: opt -passes=print-alias-sets -S -o - < %s 2>&1 | FileCheck %s
@s = global i8 1, align 1
@d = global i8 2, align 1
; CHECK: Alias sets for function 'test_known_size':
; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Memory locations: (ptr %d, LocationSize::precise(1))
define void @test_known_size(ptr noalias %d) {
entry:
call void @llvm.memset.p0.i64(ptr align 1 %d, i8 0, i64 1, i1 false)
ret void
}
; CHECK: Alias sets for function 'test_unknown_size':
; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Memory locations: (ptr %d, unknown after)
define void @test_unknown_size(ptr noalias %d, i64 %len) {
entry:
call void @llvm.memset.p0.i64(ptr align 1 %d, i8 0, i64 %len, i1 false)
ret void
}
; CHECK: Alias sets for function 'test_atomic_known_size':
; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Memory locations: (ptr %d, LocationSize::precise(1))
define void @test_atomic_known_size(ptr noalias %d) {
entry:
call void @llvm.memset.element.unordered.atomic.p0.i32(ptr align 1 %d, i8 0, i64 1, i32 1)
ret void
}
; CHECK: Alias sets for function 'test_atomic_unknown_size':
; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Memory locations: (ptr %d, unknown after)
define void @test_atomic_unknown_size(ptr noalias %d, i64 %len) {
entry:
call void @llvm.memset.element.unordered.atomic.p0.i32(ptr align 1 %d, i8 0, i64 %len, i32 1)
ret void
}
declare void @llvm.memset.p0.i64(ptr %dest, i8 %val,
i64 %len, i1 %isvolatile)
declare void @llvm.memset.element.unordered.atomic.p0.i32(ptr %dest,
i8 %value,
i64 %len,
i32 %element_size)