This is an archive of the discontinued LLVM Phabricator instance.

[LNICM] Fix crashing problem
AbandonedPublic

Authored by uint256_t on Sep 11 2021, 11:25 AM.

Details

Summary

This patch fixes the problems reported in https://reviews.llvm.org/D107219.
Two crashed cases are mentioned there:

  1. LNICM tries to sink an instruction whose users are used in the current loop, and crash.
  2. LNICM tries to sink an instruction whose (PHI) user prevents from sinking for some reasons, and crash.

Diff Detail

Event Timeline

uint256_t created this revision.Sep 11 2021, 11:25 AM
uint256_t requested review of this revision.Sep 11 2021, 11:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2021, 11:25 AM
uint256_t edited subscribers, added: uabelho; removed: asbirlea.Sep 11 2021, 11:26 AM

I've verified that this patch solves the crash I saw.

As for the actual fix, I don't know the code so someone familiar with LICM should review it.

Thanks!

uabelho edited reviewers, added: nikic, Whitney, lebedev.ri; removed: uabelho.Sep 13 2021, 1:41 AM
fhahn requested changes to this revision.Sep 13 2021, 1:51 AM
fhahn added a subscriber: fhahn.

Could you please describe the issue and fix in the pat h description? Is there anything we can do to proactively check for similar issues in the LICM code? Originally there were very few places which required special handling for the loop-nest mode, but now it seems more widespread changes might be necessary.

llvm/test/Transforms/LICM/lnicm-crash.ll
5

it would be good to check for something other than just the return code in this test. Also, can you clean up the basic block names and maybe get rid of the unreachable?

This revision now requires changes to proceed.Sep 13 2021, 1:51 AM
uint256_t added inline comments.Sep 13 2021, 2:01 AM
llvm/test/Transforms/LICM/lnicm-crash.ll
5

I was forgetting to clean up this test case. Actually this is the original test case (from https://reviews.llvm.org/D107219) to reproduce a crash.
I'll clean up the block names and unreachables. Thank you.

bjope added a subscriber: bjope.Oct 22 2021, 4:34 AM
uint256_t updated this revision to Diff 395268.Dec 18 2021, 1:21 AM
uint256_t retitled this revision from [LNICM] Fix the crashing problem to [LNICM] Fix crashing problem.
uint256_t edited the summary of this revision. (Show Details)

Created a new revision. I think this is not a widespread change. What you do think @fhahn?

uint256_t abandoned this revision.Jun 5 2022, 6:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 6:35 PM