Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 275 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
restrict qualifier in C vs noalias attribute in LLVM IR

#1
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**](

[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?
Reply

#2
As suggested by Jens Gustedt, digging into the links brought me to the [AliasAnalysis](

[To see links please register here]

) page that states:

>The most obvious example is when the two pointers point to non-overlapping memory ranges. Another is when the two pointers are only ever used for reading memory. Another is when the memory is freed and reallocated between accesses through one pointer and accesses through the other — in this case, there is a dependence, but it’s mediated by the free and reallocation.

This solves the question: the `noalias` attribute is equivalent to the C `restrict` qualifier in function parameters.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through