This is an archive of the discontinued LLVM Phabricator instance.

[NFC]Fix possibly derefer nullptr in ComplexDeinterleavingPass.cpp
ClosedPublic

Authored by XinWang10 on Jun 28 2023, 12:28 AM.

Details

Summary

Fix static analyzer reports issue, add assert to avoid analyzer report.

Diff Detail

Event Timeline

XinWang10 created this revision.Jun 28 2023, 12:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 12:28 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
XinWang10 requested review of this revision.Jun 28 2023, 12:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 12:28 AM
igor.kirillov added inline comments.Jun 28 2023, 2:00 AM
llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
1039

If there are Muls and they are not processed, then there is no point to continue analysing Addends. Therefore it is better to have an early exit here.

Also Collect function, if it returns true, always would fill either Addends or Muls. That's why there is no way for the control flow to miss either FinalNode check in the original code. So, FinalNode can't be nullptr by that point

XinWang10 updated this revision to Diff 535304.Jun 28 2023, 2:49 AM
  • add assert instead
XinWang10 edited the summary of this revision. (Show Details)Jun 28 2023, 2:50 AM
XinWang10 added inline comments.
llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
1039

Thanks for explanation, make sense here. I want to add assert instead to mute the static analyzer check. Does this look good to you?

igor.kirillov accepted this revision.Jun 28 2023, 4:33 AM

Ok, then!

This revision is now accepted and ready to land.Jun 28 2023, 4:33 AM