<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Hack Nerd Font Mono">Hi Bandhav,</font></p>
<p><font face="Hack Nerd Font Mono"><br>
</font></p>
<p><font face="Hack Nerd Font Mono">Jeroen Dobbelaere (CC'ed) is
currently working on support for restrict qualified local
variables and struct members.</font></p>
<p><font face="Hack Nerd Font Mono">The patches exist but are not
merged yet. If you want to give it a try apply
<a class="moz-txt-link-freetext" href="https://reviews.llvm.org/D69542">https://reviews.llvm.org/D69542</a>.<br>
</font></p>
<p><font face="Hack Nerd Font Mono"><br>
</font></p>
<p><font face="Hack Nerd Font Mono">Initially I could only think of
this solution for your problem: <a class="moz-txt-link-freetext" href="https://godbolt.org/z/6WtPXJ">https://godbolt.org/z/6WtPXJ</a></font></p>
<p><font face="Hack Nerd Font Mono">Michael (CC'ed) might now
another annotation to get `llvm.access` metadata for the loop,
which should do what you intend.<br>
</font></p>
<p><font face="Hack Nerd Font Mono"><br>
</font></p>
<p><font face="Hack Nerd Font Mono">Cheers,</font></p>
<p><font face="Hack Nerd Font Mono"> Johannes<br>
</font></p>
<p><font face="Hack Nerd Font Mono"><br>
</font></p>
<div class="moz-cite-prefix">On 6/21/20 11:56 AM, Bandhav Veluri via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAKyKabgdVLec0Je85iRsNCTZ=710=MmcPt+d83SG-G8+x7MWpw@mail.gmail.com">
<pre class="moz-quote-pre" wrap="">Hi,
I'm trying to abstract some special pointers with a class, like in the
example program below:
1 #define __remote __attribute__((address_space(1)))
2 #include <stdint.h>
3
4 __remote int* A;
5 __remote int* B;
6
7 class RemotePtr {
8 private:
9 __remote int* __restrict a;
10
11 public:
12 RemotePtr(__remote int* a) : a(a) {}
13
14 __remote int& at(int n) {
15 return a[n];
16 }
17 };
18
19 int main(int argc, char** argv) {
20 RemotePtr a(A);
21 RemotePtr b(B);
22
23 #pragma unroll 4
24 for(int i=0; i<4; ++i) {
25 a.at(i) += b.at(i);
26 }
27
28 return 0;
29 }
It's given that pointer a, in each object of the class RemotePtr, is the
only pointer that can access the array pointed by it. So, I tried __remote
int* __restrict a; (line 9) construct to tell Clang the same. This doesn't
seem to work and I see no noliass in the generated IR. Specifically, I want
lines 23-26 optimized assuming no aliasing between A and B. Any reason why
Clang shouldn't annotate memory accesses in lines 23-26 with noaliass
taking line 9 into account?
The higher level problem is this: is there a way to compile lines 23-26
assuming no aliasing between A and B, by just doing something in the
RemotePtr class (so that main is clear of ugly code)? If that's not
possible, is there a way to tell Clang that lines 23-26 should assume no
aliasing at all, by some pragma?
Thank you,
Bandhav
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>