This adds an elementtype(<ty>) attribute, which can be used to attach an element type to a pointer typed argument. It is similar to byval/byref in purpose, but unlike those does not carry any specific semantics by itself. However, certain intrinsics may require it and interpret it in specific ways.
The in-tree use cases for this that I'm currently aware of are:
call ptr @llvm.preserve.array.access.index.p0(ptr elementtype(%ty) %base, i32 %dim, i32 %index) call ptr @llvm.preserve.struct.access.index.p0(ptr elementtype(%ty) %base, i32 %gep_index, i32 %di_index) ; Possibly also @llvm.preserve.union.access.index.p0(), though I think it doesn't need it. call token @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0, ptr addrspace(1) %obj)
Notably, the gc.statepoint case needs a function as element type, in which case the workaround of adding a separate %ty undef argument would not work, as arguments cannot be unsized.