This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Check for !isTailCall in isUnconditionalBranch
ClosedPublic

Authored by yota9 on Apr 1 2022, 12:00 PM.

Details

Summary

Add !isTailCall in isUnconditionalBranch check in order to sync the x86
and aarch64 and fix the fixDoubleJumps pass on aarch64.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Diff Detail

Event Timeline

yota9 created this revision.Apr 1 2022, 12:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 12:00 PM
Herald added a subscriber: ayermolo. · View Herald Transcript
yota9 requested review of this revision.Apr 1 2022, 12:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 12:00 PM
yota9 updated this revision to Diff 419827.Apr 1 2022, 12:04 PM

Add test description

Thanks for fixing! I think we should probably modify MCPlusBuilder.h instead. In that way we make the AArch64 backend behave in the same way as the X86 one.

bolt/lib/Passes/BinaryPasses.cpp
700 ↗(On Diff #419827)

This is out of sync with X86. In X86, isUnconditionalBranch only returns true if it is also not a tail call:

return Analysis->isBranch(Inst) && !isTailCall(Inst);

For consistency, AArch64MCPlusBuilder should probably do the same at MCPlusBuilder.h:356.

yota9 updated this revision to Diff 420444.Apr 5 2022, 3:53 AM

@rafauler Thanks for your suggestion, I've missed that moment, I think you're right

yota9 retitled this revision from [BOLT] Fix remove double jumps peephole pass to [BOLT] Check for !isTailCall in isUnconditionalBranch.Apr 5 2022, 3:53 AM
yota9 edited the summary of this revision. (Show Details)
Amir accepted this revision.Apr 5 2022, 7:27 AM
Amir added inline comments.
bolt/test/AArch64/ext-double-jump.s
6

We already have -nostartfiles and -nostdlib in %cflags (bolt/test/AArch64/lit.local.cfg). Do we still need -nostartfiles -nodefaultlibs here?

This revision is now accepted and ready to land.Apr 5 2022, 7:27 AM
yota9 marked an inline comment as done.Apr 5 2022, 7:29 AM
yota9 added inline comments.
bolt/test/AArch64/ext-double-jump.s
6

Basically no, but from the stand-alone test point I would like them to be in such tests, where we don't need them by design

maksfb added inline comments.Apr 5 2022, 11:39 AM
bolt/test/AArch64/ext-double-jump.s
11

nit: could you add size directives for functions in the test?

yota9 marked 2 inline comments as done.Apr 5 2022, 11:44 AM
yota9 added inline comments.
bolt/test/AArch64/ext-double-jump.s
11

Sure, will do. Does it affect something? I did it before, but usually BOLT works just fine without it, just curious

maksfb requested changes to this revision.Apr 5 2022, 11:50 AM

Actually, I'm not convinced it's a great idea to check for the tail call here.

bolt/test/AArch64/ext-double-jump.s
11

That's the proper way to mark functions in code. Ideally, you also need FDEs. Without this info, BOLT has to rely on heuristics to detect function boundaries.

This revision now requires changes to proceed.Apr 5 2022, 11:50 AM
maksfb accepted this revision.Apr 5 2022, 11:50 AM
This revision is now accepted and ready to land.Apr 5 2022, 11:50 AM
yota9 marked 2 inline comments as done.Apr 5 2022, 12:01 PM
yota9 added inline comments.
bolt/test/AArch64/ext-double-jump.s
11

Yes, I remember these heuristics, I just thought you've faced with some problems during cross-target tests enabling :)

This revision was automatically updated to reflect the committed changes.
yota9 marked an inline comment as done.
maksfb added inline comments.Apr 5 2022, 3:35 PM
bolt/test/AArch64/ext-double-jump.s
11

Ah no, it's just a nit.