[LLVMdev] GVN incorrectly handling readnone parameter attribute?
Robert Lougher
rob.lougher at gmail.com
Fri May 23 09:42:17 PDT 2014
Hi Nick,
Thanks for replying. Bug filed: http://llvm.org/bugs/show_bug.cgi?id=19842
Strangely enough, my first conclusion was that %p was being marked
readnone incorrectly as it wasn't handling the copy via @get_addr.
Somebody (not here) then pointed out the readnone definition in the
LangRef (specifically the "even though it may read or write
the memory that the pointer points to if accessed through other
pointers"). I decided the copy fell within this definition and
changed my mind and decided GVN was at fault. How should the
definition be interpreted?
Thanks,
Rob.
On 23 May 2014 04:22, Nick Lewycky <nlewycky at google.com> wrote:
> Confirmed, this is a bug. This
>
> define i32* @get_pntr(i32* %p) nounwind uwtable {
> entry:
> ret i32* %p
> }
> define void @store(i32* %p) noinline nounwind uwtable {
> entry:
> %call = call i32* @get_pntr(i32* %p)
> store i32 10, i32* %call, align 4
> ret void
> }
>
> run through opt -functionattrs gets a 'readnone' on @store's %p. That's
> wrong, it clearly stores to it. The bug is due to incorrectly handling the
> copy of the pointer made by @get_pntr, because @get_pntr itself is marked
> 'readnone'.
>
> Please file a bug.
>
> Nick
>
>
>
> On 22 May 2014 08:15, Robert Lougher <rob.lougher at gmail.com> wrote:
>>
>> Hi Philip,
>>
>> Thanks for the reply.
>>
>> On 22 May 2014 01:31, Philip Reames <listmail at philipreames.com> wrote:
>> >
>> > On 05/21/2014 02:52 PM, Robert Lougher wrote:
>> >>
>> >> On 21 May 2014 21:40, Robert Lougher <rob.lougher at gmail.com> wrote:
>> >>>
>> >>> define i32* @get_pntr(i32* readnone %p) {
>> >>> entry:
>> >>> ret i32* %p
>> >>> }
>> >>>
>> >>> define void @store(i32* nocapture readnone %p) {
>> >>> entry:
>> >>> store i32 10, i32* %p, align 4, !tbaa !1
>> >>> ret void
>> >>> }
>> >>>
>> >> Further to my first post, based on the definition of readnone on an
>> >> argument, this is also incorrect. After get_pntr() has been inlined
>> >> into store(), we are dereferencing %p, but it is still marked
>> >> readnone.
>> >>
>> >> So we seem to have a couple of issues. First GVN seems to be making
>> >> incorrect assumptions based on argument attributes, and secondly
>> >> inlining can invalidate existing attributes?
>> >
>> > I'm not clear on the GVN issue, but looking at your example IR, the
>> > readnone
>> > attribute is definitely incorrect after inlining.
>> >
>>
>> Yes. I haven't investigated it any further, but the parameter was
>> already readnone before inlining, so it looks like the attributes
>> aren't revisited afterwards. But that is just a guess.
>>
>> > A question worth asking here: does this definition of readnone make
>> > sense?
>> > I can see where it came from, but it seems to give very unintuitive
>> > reasoning here.
>> >
>>
>> Exactly. That was my point in asking here before I went any further.
>> The definition in the LangRef seems odd. If it could still be
>> accessed by another pointer, I can't see where the information is
>> useful.
>>
>> > p.s. Is this with TOT or an earlier version?
>>
>> Yes, this was with TOT as of yesterday (r209294).
>>
>> Thanks,
>> Rob.
>>
>> >
>> > Philip
>> >
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
More information about the llvm-dev
mailing list