This is an archive of the discontinued LLVM Phabricator instance.

Take alignment into account in isSafeToLoadUnconditionally
ClosedPublic

Authored by apilipenko on Jun 16 2015, 6:20 AM.

Details

Summary

Take alignment into account in isSafeToLoadUnconditionally. Separated from the D9791.

Diff Detail

Repository
rL LLVM

Event Timeline

apilipenko updated this revision to Diff 27758.Jun 16 2015, 6:20 AM
apilipenko retitled this revision from to Take alignment into account in isSafeToLoadUnconditionally.
apilipenko updated this object.
apilipenko edited the test plan for this revision. (Show Details)
apilipenko added a reviewer: sanjoy.
apilipenko added a subscriber: Unknown Object (MLST).
reames added a subscriber: reames.Jun 16 2015, 10:13 AM
reames added inline comments.
lib/Analysis/Loads.cpp
69 ↗(On Diff #27758)

Please clarify comment as to *why* we want this.

137 ↗(On Diff #27758)

From here on looks like a separate change. Please separate. Each logical change should be reviewed independently. Also, you should have a test case for each.

150 ↗(On Diff #27758)

Why should the native alignment of the pointee type influence anything? We can freely bitcast pointers before loading.

apilipenko added inline comments.Jun 16 2015, 10:49 AM
lib/Analysis/Loads.cpp
137 ↗(On Diff #27758)

Logically it's a single change to take alignment into account in this function. Actually from here on the main part of the change begins. I see no reason to split it more. Test case is also provided.

150 ↗(On Diff #27758)

If we end up here with zero AccessedAlign it means that there is load or store instruction before without explicit alignment specification. From docs about load/stores:
"A value of 0 or an omitted align argument means that the operation has the ABI alignment for the target."
"Overestimating the alignment results in undefined behavior."
So, I assume here that if previous load succeed that pointer alignment is at least ABI alignment.

apilipenko added inline comments.Jun 16 2015, 10:50 AM
lib/Analysis/Loads.cpp
69 ↗(On Diff #27758)

That is a part of load specification:
"A value of 0 or an omitted align argument means that the operation has the ABI alignment for the target."

hfinkel accepted this revision.Jun 22 2015, 6:55 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

LGTM.

This revision is now accepted and ready to land.Jun 22 2015, 6:55 PM
This revision was automatically updated to reflect the committed changes.