Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen,tbaa: fix array isassigned tbaa information #32356

Merged
merged 1 commit into from
Jun 26, 2019
Merged

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Jun 18, 2019

This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many CreateInBoundsGEP calls to include the element type (NFC).

This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many CreateInBoundsGEP calls to include the element type (NFC).
@vtjnash vtjnash added compiler:codegen Generation of LLVM IR and native code bugfix This change fixes an existing bug backport 1.0 labels Jun 18, 2019
@vtjnash vtjnash requested a review from Keno June 18, 2019 20:44
Value *res = ctx.builder.CreateZExt(ctx.builder.CreateICmpNE(load, V_null), T_int32);
Value *arrayptr = emit_bitcast(ctx, emit_arrayptr(ctx, aryv, aryex), T_pprjlvalue);
Value *slot_addr = ctx.builder.CreateInBoundsGEP(T_prjlvalue, arrayptr, idx);
Value *load = tbaa_decorate(tbaa_ptrarraybuf, ctx.builder.CreateLoad(T_prjlvalue, slot_addr));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@Keno
Copy link
Member

Keno commented Jun 25, 2019

Do you have a simple test case for the correctness regression? Maybe something like checking isassigned, assigning to the array and then checking isassigned again? Because of the incorrect TBAA, it'd probably GVN the two isassigned calls.

@vtjnash
Copy link
Member Author

vtjnash commented Jun 25, 2019

Oddly, it seems to block the desired load-store forwarding optimization (how I noticed the problem), but doesn't trigger a GVN mistake.

with:

function test(a, i)
    @inbounds begin
        if !isassigned(a, i)
            a[i] = nothing
        end
        return isassigned(a, i)
    end
end
test(Vector(undef, 1), 1)

@vtjnash vtjnash merged commit a7427aa into master Jun 26, 2019
@vtjnash vtjnash deleted the jn/21262-bug branch June 26, 2019 18:46
KristofferC pushed a commit that referenced this pull request Jul 1, 2019
This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many other CreateInBoundsGEP calls to include the element type (NFC).

(cherry picked from commit a7427aa)
@KristofferC KristofferC mentioned this pull request Jul 1, 2019
32 tasks
KristofferC pushed a commit that referenced this pull request Aug 26, 2019
This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many other CreateInBoundsGEP calls to include the element type (NFC).

(cherry picked from commit a7427aa)
@KristofferC KristofferC mentioned this pull request Aug 26, 2019
55 tasks
KristofferC pushed a commit that referenced this pull request Aug 26, 2019
This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many other CreateInBoundsGEP calls to include the element type (NFC).

(cherry picked from commit a7427aa)
KristofferC pushed a commit that referenced this pull request Feb 20, 2020
This avoids a regression (correctness and performance) caused by #21262
where we were no longer able to fold away the isnull assertion in the
case where the source also contains an explicit isassigned check.

Also upgrade many other CreateInBoundsGEP calls to include the element type (NFC).

(cherry picked from commit a7427aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants