This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] check indirect branches of callbr
ClosedPublic

Authored by nickdesaulniers on Oct 14 2022, 4:47 PM.

Details

Summary

This will be necessary to support outputs from asm goto along indirect
edges.

Test via:

$ pushd llvm/build; ninja IRTests; popd
$ ./llvm/build/unittests/IR/IRTests \
  --gtest_filter=DominatorTree.CallBrDomination

Also, return nullptr in Instruction::getInsertionPointAfterDef for
CallBrInst as was recommened in
https://reviews.llvm.org/D135997#3991427. The following phab review was
folded into this commit: https://reviews.llvm.org/D140166

Link: Link: https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 4:47 PM
nickdesaulniers requested review of this revision.Oct 14 2022, 4:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 4:47 PM
  • remove stale comment
  • fix up tests
nikic added a subscriber: nikic.Oct 19 2022, 1:21 AM
nikic added inline comments.
llvm/lib/IR/Dominators.cpp
196–197

Is it possible to just drop the callbr handling entirely? I'd expect it to be covered by the normal code now.

nickdesaulniers marked an inline comment as done.
  • drop CallBr special cases (no longer necessary), remove printf from test
nickdesaulniers retitled this revision from [WIP][Dominators] check indirect branches of callbr to [Dominators] check indirect branches of callbr.Oct 20 2022, 11:38 AM
nickdesaulniers removed subscribers: nikic, void.
efriedma accepted this revision.Oct 20 2022, 11:45 AM

LGTM, but you might need to wait to land this until after the corresponding backend changes have landed to avoid regressions. (Optimizations could introduce uses in non-default destinations.)

This revision is now accepted and ready to land.Oct 20 2022, 11:45 AM

This also needs a LangRef update.

Thanks for the reviews! I plan to build up a series and don't intend to land any until all are working. (Maybe I could have waited before pestering reviewers)

This also needs a LangRef update.

Will do.

nickdesaulniers reclaimed this revision.Dec 12 2022, 10:32 AM
This revision is now accepted and ready to land.Dec 12 2022, 10:32 AM
nikic added a comment.Dec 13 2022, 2:44 AM

After this change, https://github.com/llvm/llvm-project/blob/cca01df291300fb06879fca5113bc71567c64738/llvm/lib/IR/Instruction.cpp#L129 will have to be adjusted for the new semantics. The function should return nullptr for callbr, because there no longer exists any insert point after the callbr. I think callers should deal with this gracefully, but it will probably regress some optimizations.

void accepted this revision.Dec 21 2022, 2:31 PM

One small nit. Otherwise LGTM.

llvm/test/Verifier/callbr.ll
59–60

Could you add some "CHECK"s here? Or a comment like below (;; No issue!).

nickdesaulniers marked an inline comment as done.
  • add no issue comment to test
  • rebase, format
void accepted this revision.Jan 17 2023, 2:56 PM

Could you investigate the build failures?

Could you investigate the build failures?

@ychen any idea how my patch could be tripping this presubmit failure? I have no idea.

Could you investigate the build failures?

Looks like just a bad spot I picked for my previous rebase. Just need to re-rebase.

  • rebase (prior test failures were simply bad luck rebasing to a broken SHA)
efriedma accepted this revision.Jan 18 2023, 11:33 AM
void accepted this revision.Jan 18 2023, 2:56 PM
nickdesaulniers edited the summary of this revision. (Show Details)
  • final rebase, merge D140166, update commit message
This revision was landed with ongoing or failed builds.Feb 16 2023, 6:04 PM
This revision was automatically updated to reflect the committed changes.