This is an archive of the discontinued LLVM Phabricator instance.

[Codegen] Both sides of '&&' are same; fixed
AbandonedPublic

Authored by xbolva00 on Nov 1 2019, 4:38 PM.

Details

Summary

Found by PVS Studio

Not familiar with this code; no testcase.

Diff Detail

Event Timeline

xbolva00 created this revision.Nov 1 2019, 4:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2019, 4:38 PM

BTW, is anybody interested to help with fixing errs/warnings found by PVS Studio? List is huuuge.

xbolva00 edited the summary of this revision. (Show Details)Nov 1 2019, 5:11 PM
RKSimon accepted this revision.Nov 2 2019, 2:30 AM

LGTM by inspection

This revision is now accepted and ready to land.Nov 2 2019, 2:30 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Nov 2 2019, 8:55 AM

Does this have an observable efefceffect that can be tested?

RKSimon reopened this revision.Nov 2 2019, 10:25 AM

This might be trickier than it looks as its causing buildbot timeouts due to infinite loop in some llvm-tblgen calls (RISCVGenGlobalISel.inc is the one I've noticed).

This revision is now accepted and ready to land.Nov 2 2019, 10:25 AM
RKSimon requested changes to this revision.Nov 2 2019, 10:25 AM
This revision now requires changes to proceed.Nov 2 2019, 10:25 AM
xbolva00 added subscribers: simoncook, asb.EditedNov 2 2019, 10:33 AM

Expired timeouts were sadly caused by other commit, after that commit was reverted, major buildbots are green.

RISCV folks should look at it if this exposed bugs..

cc @asb @simoncook

But http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/10228 is red due to this patch for sure.. sad.

Gonna revert this one.

Oh!

@krasimir tried to fix it too some time ago (https://reviews.llvm.org/D61632) and failed with same error - RISCV to blame :)

simoncook added inline comments.Nov 5 2019, 3:53 AM
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
482

I'm not familiar with this part of TableGen, but trying to narrow down what about RISCV causes this issue, it seems that patterns that have sext_inreg nodes cause this infinite loop, whereby this comparison now fails, and we fall into line 490 and remove modes.

Reading the comment above, it reads to me like this comparison should instead be if either S or B contains an integer mode, rather than if both do? If I change both this and line 486 to || rather than && in addition to this change then the infinite loop disappears. I ran make check-llvm with that change, and I don't see any regression tests failing.

xbolva00 marked an inline comment as done.Nov 5 2019, 4:43 AM
xbolva00 added a subscriber: kparzysz.

This code was implemented by @kparzysz, please can you look at it?

kparzysz added inline comments.Nov 7 2019, 8:44 AM
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
482

The intent was what this change shows, i.e. if S contains an integer && B contains an integer). I don't know what's causing the timeouts, but IIRC the code at lines 505-509 used to cause some weirdness on X86 (it's been fixed since). Without knowing how the timeouts occur there isn't much that can be done.

xbolva00 abandoned this revision.Nov 7 2019, 10:20 AM

Since nobody knows what should be done, where the bug is - Abandoning.

xbolva00 added a comment.EditedNov 8 2019, 1:34 PM

@RKSimon / @hans - do you have any idea how to progress here? It is shame to have such obvious mistake in code just to keep RISC V working. Since no other targets are broken, I think this needs to be solved on RISC V side.

xbolva00 added a subscriber: hans.Nov 8 2019, 1:36 PM
hans added a comment.Nov 12 2019, 2:00 AM

@RKSimon / @hans - do you have any idea how to progress here? It is shame to have such obvious mistake in code just to keep RISC V working. Since no other targets are broken, I think this needs to be solved on RISC V side.

Maybe someone from RISC-V could try to figure out what pattern it is that's causing the problem? Perhaps one approach could be to bisect over RISC-V commits with this patch applied and seeing where the timeouts start?

lenary added a subscriber: lenary.Nov 14 2019, 8:04 AM

There is no official riscv buildbot? I think it is mandatory to have a buildbot for official (non experimental) target.

http://lab.llvm.org:8011/builders

There is no official riscv buildbot? I think it is mandatory to have a buildbot for official (non experimental) target.

The RISC-V backend is now enabled by default, so general buildbot builders are building the RISC-V backend.

Any progress?