This is an archive of the discontinued LLVM Phabricator instance.

[Scalarizer] Avoid updating the name of globals
ClosedPublic

Authored by bjope on Aug 24 2020, 10:17 AM.

Details

Summary

The "takeName" logic at the end of ScalarizerVisitor::finish
could end up renaming global variables when having simplified
and extractelement instruction to simply pick a single vector
element. If the input vector to the extractelement instruction
held pointers to global variables we ended up renaming the global
variable.
The patch make sure we only take the name of the replaced Op when
we have added new instructions that might need a useful name.

Diff Detail

Event Timeline

bjope created this revision.Aug 24 2020, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2020, 10:17 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bjope requested review of this revision.Aug 24 2020, 10:17 AM
lebedev.ri accepted this revision.Aug 24 2020, 10:24 AM

@bjope thanks! bugreport kinda skimmed my attention span, i was going to re-look today-ish.
I think this looks fine. The another alternative would be to only do that if the value-to-be-renamed is an instruction,
but then i'm not sure it's an improvement if we rename something that we reused.

This revision is now accepted and ready to land.Aug 24 2020, 10:24 AM

@bjope thanks! bugreport kinda skimmed my attention span, i was going to re-look today-ish.
I think this looks fine. The another alternative would be to only do that if the value-to-be-renamed is an instruction,
but then i'm not sure it's an improvement if we rename something that we reused.

Yes, I actually experimented with adding an isa<Instruction> check first. But then I figured there could be more uses of the scalar value that is extraced from the vector, so changing the name of that value might be more confusing compared to keeping its name. So when comparing the result I preferred this way of solving it.

This revision was automatically updated to reflect the committed changes.