Skip to content

[JITLink][AArch32] Unittest for error paths of readAddend and applyFixup functionality #69636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 9, 2023

Conversation

eymay
Copy link
Contributor

@eymay eymay commented Oct 19, 2023

This commit is part of an effort to increase coverage of AArch32 backend.

@eymay eymay requested a review from weliveindetail October 19, 2023 20:08
@eymay eymay force-pushed the cov_test_readAddend branch from 6bad67f to ee5cbe9 Compare October 19, 2023 20:12
@github-actions
Copy link

github-actions bot commented Oct 19, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Testing error paths sounds like a good addition and it might be something to consider even in a broader scope.

The current implementation looks quite generic though. It's hard to see what is the actual error messages we expect. Maybe we can improve that with matchers. Please see my inline comment for an example. It might even allow to reduce most of the createXYError() boilderplate.

Edit: And can we move it into a separate AArch32ErrorTests.cpp maybe?

What do you think?

@eymay eymay force-pushed the cov_test_readAddend branch from ee5cbe9 to a242afe Compare October 25, 2023 13:40
@eymay eymay changed the title [JITLink][AArch32] Unittest for error paths of readAddend functionality [JITLink][AArch32] Unittest for error paths of readAddend and applyFixup functionality Oct 26, 2023
@eymay eymay force-pushed the cov_test_readAddend branch from 75a795b to 5ff858d Compare November 7, 2023 06:47
Copy link
Member

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good polishing and reduction to the essentials! I left a few comments inline.

@eymay eymay force-pushed the cov_test_readAddend branch from 5ff858d to c9eb0ce Compare November 7, 2023 18:39
Copy link
Member

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Our opcode checks are not exhaustive. It's rather smoke checks. The goal is to raise a flag when we get code that we cannot handle yet. Up to you to fix the Jump24 constant here or in a separate PR (of leave it to me if you wish). Two comments with more detail inline:

static constexpr HalfWords Opcode{0xf000, 0x8000};
static constexpr HalfWords OpcodeMask{0xf800, 0x8000};
static constexpr HalfWords Opcode{0xf000, 0x9000};
static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs here state that Jump24 requires a B.W instruction. The old opcode and mask match both of its encodings: B-T3 and B-T4. We only support B-T4 right now (and I don't think Jump24 can even be applied to the other one). So indeed, we should fix both, opcode and mask, to be 0x9000.

static constexpr HalfWords Opcode{0xf000, 0xc000};
static constexpr HalfWords OpcodeMask{0xf800, 0xc000};
static constexpr HalfWords Opcode{0xf000, 0xd000};
static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call opcode and mask should both remain at 0xC000 because the input object can come with BL-T1 or BLX-T2, so we don't want to check bit0 of the most significant byte in Lo.

@eymay eymay force-pushed the cov_test_readAddend branch from c9eb0ce to 5ad2171 Compare November 8, 2023 18:11
EXPECT_THAT_EXPECTED(readAddendThumb(*G, BArm, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we deduplicate these across all test cases please?

@eymay eymay force-pushed the cov_test_readAddend branch from 5ad2171 to 563d5e0 Compare November 8, 2023 18:48
Copy link
Member

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the initiative to start testing error paths. Looking forward to applying this on a larger scale.

@eymay eymay merged commit f6d525f into llvm:main Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants