Hi,
I am observing a strange behaviour in which Clang ignores __restirct when I include some standard headers.
For example, this code:
void vec_add(int* __restrict a,
int* __restrict b,
int n) {
#pragma unroll 4
for(int i=0; i<n; ++i) {
a[i] += b[i];
}
}
results in:
; Function Attrs: nofree norecurse nounwind
define dso_local void @_Z7vec_addPiS_i(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %n) local_unnam
ed_addr #0 {
entry:
.
.
…
(note the noaliass before function arguments).
But this code:
#include
void vec_add(int* __restrict a,
int* __restrict b,
int n) {
#pragma unroll 4
for(int i=0; i<n; ++i) {
a[i] += b[i];
}
}
results in:
; Function Attrs: nofree norecurse nounwind
define dso_local void @_Z7vec_addPiS_i(i32* nocapture %a, i32* nocapture readonly %b, i32 %n) local_unnamed_addr #0 {
entry:
%cmp6 = icmp sgt i32 %n, 0
br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
.
.
…
I’m running this with LLVM RISC-V backend using RISC-V GCC compiled Newlib as the C/C++ library.
Is it not okay to use GCC libraries with LLVM? Or could this be a specific issue with Newlib’s header files misinterpreted by Clang?
Thank you,
Bandhav