This is an archive of the discontinued LLVM Phabricator instance.

AArch64: Fix end iterator dereference
ClosedPublic

Authored by arsenm on Jun 13 2016, 1:51 PM.

Details

Reviewers
rovka
Summary

Not all blocks have terminators. I'm not sure how this wasn't crashing before.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 60599.Jun 13 2016, 1:51 PM
arsenm retitled this revision from to AArch64: Fix end iterator dereference.
arsenm updated this object.
arsenm added a subscriber: llvm-commits.

It looks like this currently happens to not crash because ilist::end() points to a sentinel value which can be validly accessed. Relying on that implementation detail seems like a bad idea though, so this looks like a good idea.

lib/Target/AArch64/AArch64BranchRelaxation.cpp
265–266

Is there a particular reason you're changing this to take a reference instead of a pointer (and also getDestBlock below)? If you're doing it to emphasize "this pointer cannot be null" then it would make sense to do the same thing everywhere (i.e. in fixupConditionalBranch, invertBccCondition, etc.).

473

Making a reference only to then take the address of it when calling fixupConditionalBranch seems a little odd. I'd just stick with a pointer.

arsenm added inline comments.Jun 20 2016, 11:21 AM
lib/Target/AArch64/AArch64BranchRelaxation.cpp
473

I was trying to avoid &*I which is gross

arsenm updated this revision to Diff 65649.Jul 26 2016, 7:12 PM

Use reference parameters everywhere

rovka accepted this revision.Aug 1 2016, 2:39 AM
rovka added a reviewer: rovka.

LGTM.

This revision is now accepted and ready to land.Aug 1 2016, 2:39 AM
arsenm closed this revision.Aug 2 2016, 12:28 AM

r277427