aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-06-20 10:27:55 +0100
committerGitHub <noreply@github.com>2024-06-20 10:27:55 +0100
commit80f881485accb020345ee7e1c4c3151ec55ce590 (patch)
tree6eea7fa330650882033ab0dcf167bf198c2953cb /llvm/lib/Target
parente2296d8295516e9991cd6ca99ba193fbd232b6da (diff)
downloadllvm-80f881485accb020345ee7e1c4c3151ec55ce590.zip
llvm-80f881485accb020345ee7e1c4c3151ec55ce590.tar.gz
llvm-80f881485accb020345ee7e1c4c3151ec55ce590.tar.bz2
[LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (#94226)
This patch simplifies instruction creation by replacing all overloads of instruction constructors/Create methods that are identical other than the Instruction *InsertBefore/BasicBlock *InsertAtEnd/BasicBlock::iterator InsertBefore argument with a single version that takes an InsertPosition argument. The InsertPosition class can be implicitly constructed from any of the above, internally converting them to the appropriate BasicBlock::iterator value which can then be used to insert the instruction (or to not insert it if an invalid iterator is passed). The upshot of this is that code will be deduplicated, and all callsites will switch to calling the new unified version without any changes needed to make the compiler happy. There is at least one exception to this; the construction of InsertPosition is a user-defined conversion, so any caller that was already relying on a different user-defined conversion won't work. In all of LLVM and Clang this happens exactly once: at clang/lib/CodeGen/CGExpr.cpp:123 we try to construct an alloca with an AssertingVH<Instruction> argument, which must now be cast to an Instruction* by using `&*`. If this is more common elsewhere, it could be fixed by adding an appropriate constructor to InsertPosition.
Diffstat (limited to 'llvm/lib/Target')
0 files changed, 0 insertions, 0 deletions