This is an archive of the discontinued LLVM Phabricator instance.

[GVN] Assign new value number to calls reading memory, if there is no MemDep info.
ClosedPublic

Authored by fhahn on Aug 17 2018, 5:16 AM.

Details

Summary

Currently we assign the same value number to two calls reading the same
memory location if we do not have MemoryDependence info. Without MemDep
Info we cannot guarantee that there is no store between the two calls, so we
have to assign a new number to the second call.

I added a new option EnableMemDep to enable/disable running
MemoryDependenceAnalysis and also renamed NoLoads to NoMemDepAnalysis to
be more explicit what it does. It also impacts calls that read memory,
so NoLoads is a bit confusing.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Aug 17 2018, 5:16 AM

PassManagerBuilder supports a boolean DisableGVNLoadPRE, but it looks like it's only hooked up to an actual user option if you're using LTO. You could add an option to GVN.cpp to override the default, to allow testing this codepath, I guess.

lib/Transforms/Scalar/GVN.cpp
396 ↗(On Diff #161214)

Probably simpler to check MD && AA->onlyReadsMemory(C) here.

fhahn updated this revision to Diff 161706.Aug 21 2018, 6:07 AM
fhahn edited the summary of this revision. (Show Details)

Simplified, added EnableMemDep option and test.

fhahn marked an inline comment as done.Aug 21 2018, 6:07 AM
This revision is now accepted and ready to land.Aug 21 2018, 11:20 AM
This revision was automatically updated to reflect the committed changes.