Sanjoy Das via llvm-dev
2016-Jul-16 00:37 UTC
[llvm-dev] RFC: Strong GC References in LLVM
Hi Andy, Andrew Trick wrote: > At some point I stopped thinking about this as a bug and realized that > you just need to think of LLVM as modeling speculative code barriers as > memory dependence. In LLVM, it makes no sense to have a readonly > may-throw call. The problem is that that model breaks down with aggressive aliasing like: void foo(int* restrict ptr) { *ptr = 40; may_throw(); // read/write call *ptr = 50; } Now it is tempting to CSE the store of 40 to *ptr. If we can't do that then what does restrict/noalias even mean? -- Sanjoy
Andrew Trick via llvm-dev
2016-Jul-16 00:40 UTC
[llvm-dev] RFC: Strong GC References in LLVM
> On Jul 15, 2016, at 5:37 PM, Sanjoy Das <sanjoy at playingwithpointers.com> wrote: > > Hi Andy, > > Andrew Trick wrote: > > At some point I stopped thinking about this as a bug and realized that > > you just need to think of LLVM as modeling speculative code barriers as > > memory dependence. In LLVM, it makes no sense to have a readonly > > may-throw call. > > The problem is that that model breaks down with aggressive aliasing > like: > > void foo(int* restrict ptr) { > *ptr = 40; > may_throw(); // read/write call > *ptr = 50; > } > > Now it is tempting to CSE the store of 40 to *ptr. If we can't do > that then what does restrict/noalias even mean?I thought it meant ‘ptr’ doesn’t alias with other ‘restrict’ pointer args. Not that it’s an exclusive way to access the memory. I could be wrong though... In the same way you can’t have readonly-maythrow, you wouldn’t have TBAA+maythrow. Yeah, it’s not great. -Andy
Hal Finkel via llvm-dev
2016-Jul-16 03:06 UTC
[llvm-dev] RFC: Strong GC References in LLVM
----- Original Message -----> From: "Andrew Trick" <atrick at apple.com> > To: "Sanjoy Das" <sanjoy at playingwithpointers.com> > Cc: "Daniel Berlin" <dberlin at dberlin.org>, "llvm-dev" <llvm-dev at lists.llvm.org>, "Joseph Tremoulet" > <jotrem at microsoft.com>, "Oscar Blumberg" <oscar.blumberg at normalesup.org>, "Chandler Carruth" <chandlerc at gmail.com>, > "Nick Lewycky" <nlewycky at google.com>, "Hal Finkel" <hfinkel at anl.gov>, "Philip Reames" <listmail at philipreames.com>, > "Manuel Jacob" <me at manueljacob.de>, "Eli Friedman" <eli.friedman at gmail.com>, "David Majnemer" > <david.majnemer at gmail.com> > Sent: Friday, July 15, 2016 7:40:51 PM > Subject: Re: RFC: Strong GC References in LLVM > > > > On Jul 15, 2016, at 5:37 PM, Sanjoy Das > > <sanjoy at playingwithpointers.com> wrote: > > > > Hi Andy, > > > > Andrew Trick wrote: > > > At some point I stopped thinking about this as a bug and realized > > > that > > > you just need to think of LLVM as modeling speculative code > > > barriers as > > > memory dependence. In LLVM, it makes no sense to have a readonly > > > may-throw call. > > > > The problem is that that model breaks down with aggressive aliasing > > like: > > > > void foo(int* restrict ptr) { > > *ptr = 40; > > may_throw(); // read/write call > > *ptr = 50; > > } > > > > Now it is tempting to CSE the store of 40 to *ptr. If we can't do > > that then what does restrict/noalias even mean? > > I thought it meant ‘ptr’ doesn’t alias with other ‘restrict’ pointer > args. Not that it’s an exclusive way to access the memory. I could > be wrong though...It means that, within the scope of ptr, any object accessed via a pointer based on ptr is not accessed via a pointer not based on ptr. -Hal> > In the same way you can’t have readonly-maythrow, you wouldn’t have > TBAA+maythrow. Yeah, it’s not great. > > -Andy-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory