Skip to content

Commit 22cea6c

Browse files
committed
IRGen: Remove IRBuilder::StableIP
1 parent 36e46c0 commit 22cea6c

File tree

1 file changed

+0
-80
lines changed

1 file changed

+0
-80
lines changed

lib/IRGen/IRBuilder.h

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -109,67 +109,6 @@ class IRBuilder : public IRBuilderBase {
109109
IRBuilderBase::SetInsertPoint(I);
110110
}
111111

112-
/// A stable insertion point in the function. "Stable" means that
113-
/// it will point to the same location in the function, even if
114-
/// instructions are subsequently added to the current basic block.
115-
class StableIP {
116-
/// Either an instruction that we're inserting after or the basic
117-
/// block that we're inserting at the beginning of.
118-
using UnionTy = llvm::PointerUnion<llvm::Instruction *, llvm::BasicBlock *>;
119-
UnionTy After;
120-
public:
121-
StableIP() = default;
122-
explicit StableIP(const IRBuilder &Builder) {
123-
if (!Builder.hasValidIP()) {
124-
After = UnionTy();
125-
assert(!isValid());
126-
return;
127-
}
128-
129-
llvm::BasicBlock *curBlock = Builder.GetInsertBlock();
130-
assert(Builder.GetInsertPoint() == curBlock->end());
131-
if (curBlock->empty())
132-
After = curBlock;
133-
else
134-
After = &curBlock->back();
135-
}
136-
137-
/// Does this stable IP point to a valid location?
138-
bool isValid() const {
139-
return !After.isNull();
140-
}
141-
142-
/// Insert an unparented instruction at this insertion point.
143-
/// Note that inserting multiple instructions at an IP will cause
144-
/// them to end up in reverse order.
145-
void insert(llvm::Instruction *I) {
146-
assert(isValid() && "inserting at invalid location!");
147-
assert(I->getParent() == nullptr);
148-
if (auto *block = After.dyn_cast<llvm::BasicBlock*>()) {
149-
block->getInstList().push_front(I);
150-
} else {
151-
llvm::Instruction *afterInsn = After.get<llvm::Instruction*>();
152-
afterInsn->getParent()->getInstList().insertAfter(
153-
afterInsn->getIterator(), I);
154-
}
155-
}
156-
157-
// Support for being placed in pointer unions.
158-
void *getOpaqueValue() const { return After.getOpaqueValue(); }
159-
static StableIP getFromOpaqueValue(void *p) {
160-
StableIP result;
161-
result.After = UnionTy::getFromOpaqueValue(p);
162-
return result;
163-
}
164-
enum { NumLowBitsAvailable
165-
= llvm::PointerLikeTypeTraits<UnionTy>::NumLowBitsAvailable };
166-
};
167-
168-
/// Capture a stable reference to the current IP.
169-
StableIP getStableIP() const {
170-
return StableIP(*this);
171-
}
172-
173112
/// Return the LLVM module we're inserting into.
174113
llvm::Module *getModule() const {
175114
if (auto BB = GetInsertBlock())
@@ -397,23 +336,4 @@ class IRBuilder : public IRBuilderBase {
397336
} // end namespace irgen
398337
} // end namespace swift
399338

400-
namespace llvm {
401-
template <> struct PointerLikeTypeTraits<swift::irgen::IRBuilder::StableIP> {
402-
using type = swift::irgen::IRBuilder::StableIP;
403-
404-
public:
405-
static void *getAsVoidPointer(type IP) {
406-
return IP.getOpaqueValue();
407-
}
408-
static type getFromVoidPointer(void *p) {
409-
return type::getFromOpaqueValue(p);
410-
}
411-
412-
// The number of bits available are the min of the two pointer types.
413-
enum {
414-
NumLowBitsAvailable = type::NumLowBitsAvailable
415-
};
416-
};
417-
}
418-
419339
#endif

0 commit comments

Comments
 (0)