This is an archive of the discontinued LLVM Phabricator instance.

[SCCP] Fix crash when function arg is a unused basic block's address
AbandonedPublic

Authored by bcl5980 on Mar 14 2022, 1:33 AM.

Details

Summary

For now if Solver never touch a basic block, DTU will erase the basic block even if the basic block address is referenced by function args.
So check the kernel arg is block address or not, if it is we need to mark the basic block executable.

Fix #54238, #54251

Diff Detail

Event Timeline

bcl5980 created this revision.Mar 14 2022, 1:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 1:33 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bcl5980 requested review of this revision.Mar 14 2022, 1:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 1:33 AM

Per the discussion on https://github.com/llvm/llvm-project/issues/54238, my understanding is that considering the block dead is okay semantically, so I'm not sure preventing that is the right fix here. Why does the "usual" replacement of the blockaddress with 1 not work here and crash instead?

bcl5980 abandoned this revision.Mar 15 2022, 2:49 AM

OK, thanks for the review. I will close this revision

The issue is in [runIPSCCP](https://github.com/llvm/llvm-project/blob/687d20de7ffc69dd4ecdb9808aeb6d3cffcf3871/llvm/lib/Transforms/Scalar/SCCP.cpp#L500-L533). We don't clean up uses of any BlockAddresses before deleting the BasicBlock that's dead. So we basically need to do the same transform that was observed here. I'm working on a fix.