This is an archive of the discontinued LLVM Phabricator instance.

Fix a bug in caller's BFI update code after inlining.
ClosedPublic

Authored by eraman on Feb 7 2017, 5:34 PM.

Details

Summary
Multiple blocks in the callee can be mapped to a single cloned block since we prune the callee as we clone it. The existing code  iterates over the value map and clones the block frequency (and eventually scales the frequencies of the cloned blocks). Value map's  iteration is not deterministic and so the cloned block might get the frequency of any of the original blocks. The fix is to set the max of the original frequencies to the cloned block. The first block in the sequence must have this max frequency and, in the call context, subsequent blocks must have its frequency.

Diff Detail

Event Timeline

eraman created this revision.Feb 7 2017, 5:34 PM
chandlerc edited edge metadata.Feb 8 2017, 10:44 AM

Nice catch and nice test case!

lib/Transforms/Utils/InlineFunction.cpp
1415

Instead of testing and then inserting, you always want to try to insert and check whether the insert failed.

eraman updated this revision to Diff 87716.Feb 8 2017, 2:47 PM
eraman marked an inline comment as done.

Address Chandler's comment.

davidxl edited edge metadata.Feb 14 2017, 2:16 PM

This looks fine to me. Chandler may want to take a second look.

chandlerc accepted this revision.Feb 14 2017, 2:27 PM

LGTM, sorry I didn't look right after you updated it!

This revision is now accepted and ready to land.Feb 14 2017, 2:27 PM
This revision was automatically updated to reflect the committed changes.