Page MenuHomePhabricator

Specify branch probabilities for callbr dests
ClosedPublic

Authored by void on Jan 13 2020, 2:51 PM.

Details

Summary

callbr's indirect branches aren't expected to be taken, so reduce their
probabilities to 0 while increasing the default destination to 1. This
allows some code improvements through block placement.

Diff Detail

Event Timeline

void created this revision.Jan 13 2020, 2:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2020, 2:51 PM

Cool, IIRC when upstream kernel devs took a look (via some objtool bug reports) they mentioned that our block placement was backwards. The callbr-asm-branch-folding.ll change makes the most sense to me; the indirect branch is moved out of the way. (Though I would have thought branch predictors assume forward branches are taken). Did this result in any measurable performance difference?

llvm/test/CodeGen/X86/callbr-asm.ll
81

The top of this file mentions ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py. Did update_llc_test_checks.py really remove this .p2align?

void updated this revision to Diff 249808.Mar 11 2020, 5:56 PM

Rebase patch.

void marked an inline comment as done.Mar 11 2020, 5:57 PM
void added inline comments.
llvm/test/CodeGen/X86/callbr-asm.ll
81

I don't know how this was removed. I've never had to deal with update_llc_test_checks.py.

void updated this revision to Diff 249810.Mar 11 2020, 6:19 PM

Run update_llc_test_checks.py on the testcase.

void marked an inline comment as done.Mar 11 2020, 6:19 PM

PTAL.

llvm/test/CodeGen/X86/callbr-asm.ll
81

Okay. I figured out how to run it. Done.

nickdesaulniers accepted this revision.Mar 11 2020, 6:25 PM
This revision is now accepted and ready to land.Mar 11 2020, 6:25 PM
Harbormaster completed remote builds in B48917: Diff 249810.
This revision was automatically updated to reflect the committed changes.