This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix minor bug to avoid a failure in createTailCallBranchInstr
ClosedPublic

Authored by stefanp on Dec 18 2017, 9:03 AM.

Details

Summary

It looks like dl = MBBI->getDebugLoc(); is correctly guarded by if (MBBI != MBB.end()) but later on in the same function unsigned RetOpcode = MBBI->getOpcode(); is not guarded so it is possible to reach unsigned RetOpcode = MBBI->getOpcode(); in a situation where MBBI is actually MBB.end().

If MBBI == MBB.end() then we don't need to execute the function at all. Added a guard to do that.

Diff Detail

Repository
rL LLVM

Event Timeline

stefanp created this revision.Dec 18 2017, 9:03 AM
hfinkel accepted this revision.Dec 19 2017, 9:12 PM

LGTM

This revision is now accepted and ready to land.Dec 19 2017, 9:12 PM
stefanp updated this revision to Diff 127744.Dec 20 2017, 9:08 AM

@hfinkel
Hi Hal,
Thank you for the approval. After doing a bit more investigation I realized that the condition should always be true. Before calling this function we always check that this is a return block. Therefore, I've change it slightly so that the guard is now an assert.

@hfinkel
Hi Hal,
Thank you for the approval. After doing a bit more investigation I realized that the condition should always be true. Before calling this function we always check that this is a return block. Therefore, I've change it slightly so that the guard is now an assert.

Sounds good; please proceed. The rest of the code clearly assumes that the iterator is valid.

This revision was automatically updated to reflect the committed changes.