
Currently, we specify that the ptrmask intrinsic allows the mask to have any size, which will be zero-extended or truncated to the pointer size. However, what semantics of the specified GEP expansion actually imply is that the mask is only meaningful up to the pointer type *index* size -- any higher bits of the pointer will always be preserved. In other words, the mask gets 1-extended from the index size to the pointer size. This is also the behavior we want for CHERI architectures. This PR makes two changes: * It spells out the interaction with the pointer type index size more explicitly. * It requires that the mask matches the pointer type index size. The intention here is to make handling of this intrinsic more robust, to avoid accidental mix-ups of pointer size and index size in code generating this intrinsic. If a zero-extend or truncate of the mask is desired, it should just be done explicitly in IR. This also cuts down on the amount of testing we have to do, and things transforms needs to check for. As far as I can tell, we don't actually support pointers with different index type size at the SDAG level, so I'm just asserting the sizes match there for now. Out-of-tree targets using different index sizes may need to adjust that code.
15 lines
440 B
LLVM
15 lines
440 B
LLVM
; RUN: llc -mtriple=arm64-apple-iphoneos -stop-after=finalize-isel %s -o - | FileCheck %s
|
|
|
|
declare ptr @llvm.ptrmask.p0.i64(ptr , i64)
|
|
|
|
; CHECK-LABEL: name: test1
|
|
; CHECK: %0:gpr64 = COPY $x0
|
|
; CHECK-NEXT: %1:gpr64sp = ANDXri %0, 8052
|
|
; CHECK-NEXT: $x0 = COPY %1
|
|
; CHECK-NEXT: RET_ReallyLR implicit $x0
|
|
|
|
define ptr @test1(ptr %src) {
|
|
%ptr = call ptr @llvm.ptrmask.p0.i64(ptr %src, i64 72057594037927928)
|
|
ret ptr %ptr
|
|
}
|