This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fixed constexpr expansion to handle multiple uses
ClosedPublic

Authored by rampitec on Jun 16 2021, 4:01 PM.

Details

Summary

Recently added convertConstantExprsToInstructions() does not handle
a case when a same ConstantExpr used multiple times in the same
instruction. A first use is replaced and the rest of the uses in the
instruction are replaced as well with the replaceUsesOfWith(). Then
function attempts to replace a constant already destroyed.

So far this interface is only used by the AMDGPU BE.

Diff Detail

Event Timeline

rampitec created this revision.Jun 16 2021, 4:01 PM
rampitec requested review of this revision.Jun 16 2021, 4:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2021, 4:02 PM
Herald added a subscriber: wdng. · View Herald Transcript
tra added a comment.Jun 16 2021, 4:48 PM

I've tested it on the full code which triggered the issue and this patch fixes the issue. Thank you for fixing it promptly.

tra accepted this revision.Jun 16 2021, 4:53 PM
tra added inline comments.
llvm/lib/IR/ReplaceConstant.cpp
87

Do we need/want to bump the initial set size? I'd assume that it would need to be larger now that we keep track of all operands.

This revision is now accepted and ready to land.Jun 16 2021, 4:53 PM
rampitec added inline comments.Jun 16 2021, 4:56 PM
llvm/lib/IR/ReplaceConstant.cpp
87

Actually I think even 8 is too much :) Usually expressions are way shorter.

This revision was landed with ongoing or failed builds.Jun 16 2021, 4:58 PM
This revision was automatically updated to reflect the committed changes.