07-26-2023, 07:23 PM
my question is related to the different semantics of the **restrict** qualifier in C and the **noalias** attribute in LLVM when they are used as function parameters.
According to the [LLVM documentation for **noalias**](
>This indicates that objects accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value.
In case of the **restrict** qualifier, the draft of the [C11 (Example 3, page124, sect. 6.7.3.1)]( ) puts an example where there is aliasing between two **restrict** arguments, which is fine as long as they only read data:
void h(int n, int * restrict p, int * restrict q, int * restrict r) {
int i;
for (i = 0; i < n; i++)
p[i] = q[i] + r[i];
}
To me, it seems as if the example given above would not satisfy the semantics of **noalias**. Is this the case?
According to the [LLVM documentation for **noalias**](
[To see links please register here]
):>This indicates that objects accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value.
In case of the **restrict** qualifier, the draft of the [C11 (Example 3, page124, sect. 6.7.3.1)]( ) puts an example where there is aliasing between two **restrict** arguments, which is fine as long as they only read data:
void h(int n, int * restrict p, int * restrict q, int * restrict r) {
int i;
for (i = 0; i < n; i++)
p[i] = q[i] + r[i];
}
To me, it seems as if the example given above would not satisfy the semantics of **noalias**. Is this the case?