diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-06-20 10:27:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 10:27:55 +0100 |
commit | 80f881485accb020345ee7e1c4c3151ec55ce590 (patch) | |
tree | 6eea7fa330650882033ab0dcf167bf198c2953cb /polly | |
parent | e2296d8295516e9991cd6ca99ba193fbd232b6da (diff) | |
download | llvm-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 'polly')
-rw-r--r-- | polly/include/polly/CodeGen/IRBuilder.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/polly/include/polly/CodeGen/IRBuilder.h b/polly/include/polly/CodeGen/IRBuilder.h index 825bdd9..ffca887 100644 --- a/polly/include/polly/CodeGen/IRBuilder.h +++ b/polly/include/polly/CodeGen/IRBuilder.h @@ -123,9 +123,8 @@ public: IRInserter(ScopAnnotator &A) : Annotator(&A) {} void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, - llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const override { - llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt); + llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, InsertPt); if (Annotator) Annotator->annotate(I); } |