Skip to content
Commit 379de123 authored by Nikita Popov's avatar Nikita Popov
Browse files

[InstCombine] Preserve instruction name in replaceInstUsesWith()

Currently InstCombine folds using the
`return replaceInstUsesWith(V, Builder.CreateFoo())`
pattern do not preserve the original name of the instruction.
To preserve the name, you either have to use something like
`return FooInst::Create(...)` which is usually less nice, or go
out of the way to preserve the name with takeName(). We often
don't do that.

This patch instead preserves the name in replaceInstUsesWith()
when replacing a named instruction with an unnamed instruction.
To be conservative, I also added a zero-use check, which is a
proxy for the case where the instruction was just created, rather
than an existing one reused. Possibly we could drop that part.

As InstCombine tests are robust against renames this does not
cause any test diffs, so I regenerated a random test to show the
effects.

Differential Revision: https://reviews.llvm.org/D140192
parent cb3f415c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment