This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinter] fix nullptr dereference for MBBs with hasAddressTaken property without BB
ClosedPublic

Authored by ivafanas on Aug 15 2021, 11:28 AM.

Details

Summary

Basic block pointer is dereferenced unconditionally for MBBs with hasAddressTaken property.

MBBs might have hasAddressTaken property without reference to BB. Backend developers must assign fake BB to MBB to workaround this issue and it should be fixed.

Diff Detail

Event Timeline

ivafanas created this revision.Aug 15 2021, 11:28 AM
ivafanas requested review of this revision.Aug 15 2021, 11:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2021, 11:28 AM

Could you add a test case for this? Or is it not reachable with any existing/in-tree target?

Could you add a test case for this? Or is it not reachable with any existing/in-tree target?

Yes, we have got a crash on custom out-of-tree target.
I've reviewed in-tree targets where setHasAddressTaken is called and have not found MBB without BB.

Summary message to this review http://reviews.llvm.org/D13774 gives me a bit of hope that fix will be accepted.

Could you add a test case for this? Or is it not reachable with any existing/in-tree target?

Yes, we have got a crash on custom out-of-tree target.
I've reviewed in-tree targets where setHasAddressTaken is called and have not found MBB without BB.

Summary message to this review http://reviews.llvm.org/D13774 gives me a bit of hope that fix will be accepted.

Fair enough - I'll leave this one to @rnk then

rnk accepted this revision.Aug 16 2021, 9:29 AM

lgtm

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
3287

@dblaikie, for reference, other code checks for BB nullability, they are optional.

This revision is now accepted and ready to land.Aug 16 2021, 9:29 AM

@rnk , @dblaikie

I do not have commit access.
Could you please help me to commit this patch ?

Thank you!