I would like to know if the noalias
/readonly
annotation sticks
to a pointer if it travels through another function. Eg:
define void @main(){
%x = alloca i16
store i16 0, ptr %x
%1 = call void @subfunc(%x,%0)
ret %1
define void @subfunc(i16 *readonly dereference{2} noalias data,i8* dereference{2} modify){
%0 = call Ptr @lauder(%data)
%1 = getelementptr i8 i16* i8 1
%2 = load i8 ptr %1
store i8 %data ptr %1
}
define Ptr @launder(Ptr target){
ret %target
}
Would this cause Undefined Behavior? It might because I am writing through a pointer marked readonly
, but the the data written to is never accessed in the function and the pointer is passed through a different function first. If it is Undefined Behavior, is there a way to change @launder
so it does work?