This is an archive of the discontinued LLVM Phabricator instance.

[ISEL][BitTestBlock] pre-commit test for D109103
ClosedPublic

Authored by nickdesaulniers on Sep 1 2021, 4:09 PM.

Details

Summary

Upload a test that shows ISEL taking a SwitchInst that has an
unreachable BB for a default target being lowered to an unconditional
jump off the end of a function.

Link: https://bugs.llvm.org/show_bug.cgi?id=50080
Link: https://github.com/ClangBuiltLinux/linux/issues/679
Link: https://github.com/ClangBuiltLinux/linux/issues/1440

Diff Detail

Event Timeline

nickdesaulniers created this revision.Sep 1 2021, 4:09 PM
nickdesaulniers requested review of this revision.Sep 1 2021, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2021, 4:09 PM

No need for reviewing this, just commit :)

No need for reviewing this, just commit :)

Perhaps, but if D109103 is not accepted, then it might not be adding anything interesting to the existing test coverage. I'll wait to see how the review of D109103 before committing, then push them out together.

hans added inline comments.Sep 2 2021, 7:03 AM
llvm/test/CodeGen/X86/SwitchLowering.ll
78

I guess it doesn't make sense if you push them together, but if you want to pre-commit this now, I'd put a "FIXME: Get rid of this conditional jump and bit test, see PRxxx".

  • add llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll from D109103, add -global-isel=1 coverage.
  • remember to git add new test ;)
llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll
7

Is adding this much MIR withought llvm/utils/update_mir_test_checks.py being runable frowned upon?

llvm/utils/update_mir_test_checks.py doesn't work for this test, as written.

  • add fixme to other test
nickdesaulniers marked an inline comment as done.Sep 2 2021, 1:00 PM
hans added inline comments.Sep 3 2021, 5:36 AM
llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll
7

I don't know, but why are you doing MIR checks instead of the final assembly, which should be less verbose and therefore hopefully more robust?

nickdesaulniers added inline comments.Sep 7 2021, 2:15 PM
llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll
7

Fair question.

IMO ISEL is pass that makes the decisions here that are relevant, so ISEL is the unit that should be tested.

Running all backend passes is an integration test of multiple passes, and is what llvm/test/CodeGen/X86/SwitchLowering.ll does. So we have an existing integration test of all backend passes with: llvm/test/CodeGen/X86/SwitchLowering.ll, and newly added unit tests of ISEL with llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll.

Would you prefer I convert llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll to check ASM rather than MIR? Do other reviewers agree?

craig.topper added inline comments.Sep 7 2021, 2:33 PM
llvm/test/CodeGen/X86/SwitchLowering.ll
67

predecessor*

llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll
4

I think SDISEL would be a better abbreviation. It's used in other places in the codebase

7

Is the empty basic block guaranteed to be at the end of the function in the ASM output. That's the only way to demonstrate the bug from the ASM I think. The MIR shows the predecessor and successor lists which makes it more obvious.

  • s/SISEL/SDISEL/g
nickdesaulniers marked an inline comment as done.Sep 7 2021, 2:57 PM
nickdesaulniers marked an inline comment as done.
  • s/predacessor/predecessor/g
nickdesaulniers added inline comments.Sep 7 2021, 3:00 PM
llvm/test/CodeGen/X86/switch-bit-test-unreachable-default.ll
7

Is the empty basic block guaranteed to be at the end of the function in the ASM output.

For this input, it happens to be. I don't know about guaranteed though.

The MIR shows the predecessor and successor lists which makes it more obvious.

So +2 then? :)

This revision is now accepted and ready to land.Sep 7 2021, 4:17 PM
hans accepted this revision.Sep 8 2021, 12:31 AM

lgtm

This revision was landed with ongoing or failed builds.Sep 8 2021, 9:48 AM
This revision was automatically updated to reflect the committed changes.