Skip to content

[GVN, EarlyCSE, Missed Opt] Load from memory after invariant.end is undef #21185

@preames

Description

@preames
Bugzilla Link 20811
Version trunk
OS Linux
Attachments Failing test case for GVN
CC @fhahn,@hfinkel

Extended Description

Currently, GVN has handling to remove a load following a invariant.start with no intervening stores since the memory is undefined and the load can be replaced with undef. This is an analogous case for invariant.end which is not implemented. Once the lifetime of a memory region has ended, the value of the memory becomes undefined. As a result, a load from such memory should be replaced with undef.

Here's the example case (also attached):
define i8 @​test(i8* %P) nounwind {
entry:
call void @​llvm.lifetime.end(i64 32, i8* %P)
%0 = load i8* %P <-- this load is undefined
ret i8 %0
}

The failing test case I've attached is for GVN, but EarlyCSE has the same issue. (In fact, this load is not currently removed by an pass in -O3.) As mentioned in 20809, it would be nice if the logic in question could be refactored to be sharable between the two passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm:GVNGVN and NewGVN stages (Global value numbering)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions