This is an archive of the discontinued LLVM Phabricator instance.

[MemorySSA] Add expesive check for validating clobber accesses.
ClosedPublic

Authored by asbirlea on Aug 27 2018, 3:01 PM.

Diff Detail

Event Timeline

asbirlea created this revision.Aug 27 2018, 3:01 PM

Thanks for this!

lib/Analysis/MemorySSA.cpp
456

LLVM_ATTRIBUTE_UNUSED is probably unneeded; we have a member function that calls this regardless of whether NDEBUG/EXPENSIVE_CHECKS are on

463

Is it reasonable to not involve the walker here at all? :)

I ask because, if EXPENSIVE_CHECKS are on, the walker should already be calling checkClobberSanity on everything it hands back. So I think the only coverage we need out of this "we have these accesses that report isOptimized() == true. Let's make sure that the optimization is valid." (which it might have been originally, but then the IR+MemorySSA were changed and now it's not)

1695

This appears unused?

1701

It seems a bit awkward that we're casting this to a MUD, then extracting the instruction, then looking the MUD back up, then casting it to a MUD (in checkClobberSanityInstruction).

Since this is the only user of checkClobberSanityInstruction, would it make sense to manually inline it in this function and simplify a bit?

asbirlea updated this revision to Diff 162960.Aug 28 2018, 2:48 PM

Address comments. Undo const-ifies no longer needed.

asbirlea marked 4 inline comments as done.Aug 28 2018, 2:51 PM
asbirlea added inline comments.
lib/Analysis/MemorySSA.cpp
1695

I was using this locally in a unittest, but it doesn't make sense to have unittests assert, so removing it.

asbirlea marked an inline comment as done.Aug 28 2018, 2:54 PM
asbirlea added inline comments.
lib/Analysis/MemorySSA.cpp
1705

Nit: keep the const up until upward_defs_begin and const_cast there?
(Worklist can be ConstMemoryAccessPair).
This seemed cleaner, but I'm ok with it either way.

LGTM after the requested nit. Thanks again!

lib/Analysis/MemorySSA.cpp
1705

Nit: keep the const up until upward_defs_begin and const_cast there?

Yes, please.

Also please add a FIXME or note that, given infinite free time, we should probably refactor to make upward_defs_iterator respect constness...

It's a slightly larger change, but it pushes this const_cast as close to the point of "here's where this isn't annotated with const but logically is" as we can easily get it, which makes the safety of the const_cast a bit easier to reason about IMO (and keeps the API a bit cleaner).

This revision is now accepted and ready to land.Aug 29 2018, 10:57 AM
asbirlea marked 3 inline comments as done.Aug 29 2018, 11:11 AM
asbirlea updated this revision to Diff 163147.Aug 29 2018, 11:14 AM

Missed an update.

This revision was automatically updated to reflect the committed changes.