aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/BasicBlock.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2023-10-17 15:08:58 +0100
committerJeremy Morse <jeremy.morse@sony.com>2023-10-17 15:24:44 +0100
commit088d272e83259a5d8e577a3d2e62012c42a9f9db (patch)
tree13ecadbc9a249299328a94b0d7c01e283eb44711 /llvm/lib/IR/BasicBlock.cpp
parent81d8fa5a1d01e1cd00865966957dba74b5e8613f (diff)
downloadllvm-088d272e83259a5d8e577a3d2e62012c42a9f9db.zip
llvm-088d272e83259a5d8e577a3d2e62012c42a9f9db.tar.gz
llvm-088d272e83259a5d8e577a3d2e62012c42a9f9db.tar.bz2
[ADT][DebugInfo][RemoveDIs] Add extra bits to ilist_iterator for debug-info
...behind an experimental CMAKE option that's off by default. This patch adds a new ilist-iterator-like class that can carry two extra bits as well as the usual node pointer. This is part of the project to remove debug-intrinsics from LLVM: see the rationale here [0], they're needed to signal whether a "position" in a BasicBlock includes any debug-info before or after the iterator. This entirely duplicates ilist_iterator, attempting re-use showed it to be a false economy. It's enable-able through the existing ilist_node options interface, hence a few sites where the instruction-list type needs to be updated. The actual main feature, the extra bits in the class, aren't part of the class unless the cmake flag is given: this is because there's a compile-time cost associated with it, and I'd like to get everything in-tree but off-by-default so that we can do proper comparisons. Nothing actually makes use of this yet, but will do soon, see the Phab patch stack. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939 Differential Revision: https://reviews.llvm.org/D153777
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r--llvm/lib/IR/BasicBlock.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index d6677aa..46b1a3b 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -42,7 +42,8 @@ template <> void llvm::invalidateParentIListOrdering(BasicBlock *BB) {
// Explicit instantiation of SymbolTableListTraits since some of the methods
// are not in the public header file...
-template class llvm::SymbolTableListTraits<Instruction>;
+template class llvm::SymbolTableListTraits<Instruction,
+ ilist_iterator_bits<true>>;
BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
@@ -221,7 +222,13 @@ const Instruction* BasicBlock::getFirstNonPHI() const {
}
BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
- return getFirstNonPHI()->getIterator();
+ const Instruction *I = getFirstNonPHI();
+ BasicBlock::const_iterator It = I->getIterator();
+ // Set the head-inclusive bit to indicate that this iterator includes
+ // any debug-info at the start of the block. This is a no-op unless the
+ // appropriate CMake flag is set.
+ It.setHeadBit(true);
+ return It;
}
const Instruction *BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
@@ -261,6 +268,10 @@ BasicBlock::const_iterator BasicBlock::getFirstInsertionPt() const {
const_iterator InsertPt = FirstNonPHI->getIterator();
if (InsertPt->isEHPad()) ++InsertPt;
+ // Set the head-inclusive bit to indicate that this iterator includes
+ // any debug-info at the start of the block. This is a no-op unless the
+ // appropriate CMake flag is set.
+ InsertPt.setHeadBit(true);
return InsertPt;
}