This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Add AArch64 behavior to existing MFS tests
ClosedPublic

Authored by dhoekwater on Aug 9 2023, 4:51 PM.

Details

Summary

X86 and AArch64 have some small differences in output because of non-MFS
factors (such as encoding function calls as callq vs bl). Add
AArch64 checks for tests where output varies between platforms even
if MFS logic doesn't. Add a debug flag to run MFS on any target.
Fix the encoding of nops in bbsections.

Without this change, there is no way to test that MFS functions correctly on AArch64.

Diff Detail

Event Timeline

dhoekwater created this revision.Aug 9 2023, 4:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 4:51 PM
dhoekwater edited the summary of this revision. (Show Details)Aug 17 2023, 11:10 AM

Rebase onto other MFS tests and fix the BBsections code that makes the test crash

dhoekwater published this revision for review.Aug 17 2023, 11:29 AM
dhoekwater edited reviewers, added: rahmanl; removed: snehasish, xur.
dhoekwater edited the summary of this revision. (Show Details)
dhoekwater edited the summary of this revision. (Show Details)
dhoekwater retitled this revision from [CodeGen] Add AArch64 behavior to existing MFS tests (NFC) to [CodeGen] Add AArch64 behavior to existing MFS tests.
dhoekwater edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 11:31 AM

Don't warn for AArch64 if mfs-ignore-triple is enabled

rahmanl added inline comments.Aug 17 2023, 12:27 PM
llvm/lib/CodeGen/BasicBlockSections.cpp
294 ↗(On Diff #551202)

Is this because of ARM? Maybe add a comment to explain the rationale.

llvm/lib/CodeGen/MachineFunctionSplitter.cpp
73 ↗(On Diff #551202)

How about introducing a permanent option named SkipUnsupportedTriple and default it True so we can use it for any future architectures?

dhoekwater marked an inline comment as done.Aug 17 2023, 12:50 PM
dhoekwater added inline comments.
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
73 ↗(On Diff #551202)

I'm onboard with making this a permanent flag for testing purposes only, but I'm not sure about inverting and defaulting to true. Isn't it standard to have default-false hidden flags that enable some special behavior (as opposed to default-true hidden flags that enable the default behavior)?

For example, most of the cl::opt<bool> options in llvm/lib/Analysis/InlineCost.cpp follow this pattern.

rahmanl added inline comments.Aug 17 2023, 12:57 PM
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
73 ↗(On Diff #551202)

Up to you. I thought this naming better matches with the current code (UnsupportedTriple and isSupportedTriple). Ignore doesn't fully convey what the flag actually does.

dhoekwater marked 2 inline comments as done.

Add comments

Rename the flag to split functions on unsupported targets

dhoekwater marked an inline comment as done.Aug 17 2023, 2:48 PM
rahmanl added inline comments.Aug 17 2023, 3:37 PM
llvm/lib/CodeGen/BasicBlockSections.cpp
294 ↗(On Diff #551202)

I see, this is target specific now. Although this code was target-specific before too, but we only wanted code for X86. Do you think we should implement insertNoop (https://llvm.org/doxygen/classllvm_1_1TargetInstrInfo.html#a4ee57d5d6295dfeb44f3b55301b20020) for X86 and AArch64 now?

llvm/lib/CodeGen/MachineFunctionSplitter.cpp
71 ↗(On Diff #551281)

Even better naming than mine!

dhoekwater added inline comments.Aug 17 2023, 3:50 PM
llvm/lib/CodeGen/BasicBlockSections.cpp
294 ↗(On Diff #551202)

Yes! That's exactly what I was looking for, but I couldn't find the function since I was looking for something like "addNop". Should we do that in this patch or should I make another?

rahmanl added inline comments.Aug 17 2023, 4:31 PM
llvm/lib/CodeGen/BasicBlockSections.cpp
294 ↗(On Diff #551202)

Right. Separate the entire avoidZeroOffsetLandingPad changes into its own patch if you can. You might get new reviewers when implement TargetInstrInfo.

dhoekwater marked an inline comment as done.Aug 17 2023, 4:33 PM
dhoekwater added inline comments.
llvm/lib/CodeGen/BasicBlockSections.cpp
294 ↗(On Diff #551202)

Unfortunately, we need AArch64 tests to test the avoidZeroOffsetLandingPad changes, and we need the changes so that the tests don't crash on AArch64.

dhoekwater marked 2 inline comments as done.

Implement the AArch64 InsertNoop hook and use it so that Arm tests don't crash

shenhan accepted this revision.Aug 18 2023, 2:14 PM
shenhan added inline comments.
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
72 ↗(On Diff #551617)

nit: "mfs" already contains "split", so mfs-split-xxx seems a little bit redundant. "mfs-allow-unsupported-triple" seems more aligned with the variable name.

150 ↗(On Diff #551617)

Thanks for fixing the format.

This revision is now accepted and ready to land.Aug 18 2023, 2:14 PM
This revision was landed with ongoing or failed builds.Aug 18 2023, 6:06 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 6:06 PM
thakis added a subscriber: thakis.Aug 19 2023, 3:04 AM

This breaks tests on windows: http://45.33.8.238/win/82918/step_7.txt

Please take a look and revert for now if it takes a while to fix.