-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| 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.