Document opt::Instruction::InsertBefore methods (#2751)
diff --git a/source/opt/instruction.cpp b/source/opt/instruction.cpp
index f8c837b..ec73640 100644
--- a/source/opt/instruction.cpp
+++ b/source/opt/instruction.cpp
@@ -372,6 +372,11 @@
return subtype;
}
+Instruction* Instruction::InsertBefore(std::unique_ptr<Instruction>&& i) {
+ i.get()->InsertBefore(this);
+ return i.release();
+}
+
Instruction* Instruction::InsertBefore(
std::vector<std::unique_ptr<Instruction>>&& list) {
Instruction* first_node = list.front().get();
@@ -382,11 +387,6 @@
return first_node;
}
-Instruction* Instruction::InsertBefore(std::unique_ptr<Instruction>&& i) {
- i.get()->InsertBefore(this);
- return i.release();
-}
-
bool Instruction::IsValidBasePointer() const {
uint32_t tid = type_id();
if (tid == 0) {
diff --git a/source/opt/instruction.h b/source/opt/instruction.h
index 034da76..d507d6c 100644
--- a/source/opt/instruction.h
+++ b/source/opt/instruction.h
@@ -398,8 +398,13 @@
inline bool operator!=(const Instruction&) const;
inline bool operator<(const Instruction&) const;
- Instruction* InsertBefore(std::vector<std::unique_ptr<Instruction>>&& list);
+ // Takes ownership of the instruction owned by |i| and inserts it immediately
+ // before |this|. Returns the insterted instruction.
Instruction* InsertBefore(std::unique_ptr<Instruction>&& i);
+ // Takes ownership of the instructions in |list| and inserts them in order
+ // immediately before |this|. Returns the first inserted instruction.
+ // Assumes the list is non-empty.
+ Instruction* InsertBefore(std::vector<std::unique_ptr<Instruction>>&& list);
using utils::IntrusiveNodeBase<Instruction>::InsertBefore;
// Returns true if |this| is an instruction defining a constant, but not a