Skip to content

Commit

Permalink
Remove unused instruction checkHasInstance
Browse files Browse the repository at this point in the history
Summary: .

Reviewed By: neildhar

Differential Revision: D42297941

fbshipit-source-id: 9e7a96cf53a56537f1b21fe0ea536ea5dc467cd5
  • Loading branch information
Tzvetan Mikov authored and facebook-github-bot committed Jan 10, 2023
1 parent 504a4d4 commit 2ffd972
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 125 deletions.
10 changes: 0 additions & 10 deletions doc/IR.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,6 @@ Arguments | This instruction takes one parameter, which is the register that con
Semantics | This instruction is a terminator instruction that will transition the control to the CatchInst that covers this instruction with closest scope.
Effects | May read and write memory.

### CheckHasInstanceInst

CheckHasInstanceInst | _
--- | --- |
Description | Check whether an object has a particular instance.
Example | %0 = CheckHasInstanceInst %check_result, %left, %right, %onTrue, %onFalse
Arguments | This instruction takes 5 parameters: %check_result will be a write-only stack register and holds the check result, %left and %right are the operands of instanceof, and %onTrue and %onFalse are the jump targets in case of check returns true/false.
Semantics | This instruction is generated as part of instanceof operator. It checks whether %right could possibly have %left as an instance, and returns the check result. If the checked object is invalid to have the target instance, it will throw an exception. It the check returns false, it jumps to the %jump_label.
Effects | May read or write memory.

### TryStartInst

TryStartInst | _
Expand Down
7 changes: 0 additions & 7 deletions include/hermes/IR/IRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,6 @@ class IRBuilder {

ThrowInst *createThrowInst(Value *thrownValue);

CheckHasInstanceInst *createCheckHasInstanceInst(
AllocStackInst *result,
Value *left,
Value *right,
BasicBlock *onTrue,
BasicBlock *onFalse);

TryStartInst *createTryStartInst(
BasicBlock *tryBodyBlock,
BasicBlock *catchTargetBlock);
Expand Down
1 change: 0 additions & 1 deletion include/hermes/IR/Instrs.def
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ TERMINATOR(SwitchInst, TerminatorInst)
TERMINATOR(CondBranchInst, TerminatorInst)
TERMINATOR(GetPNamesInst, TerminatorInst)
TERMINATOR(GetNextPNameInst, TerminatorInst)
TERMINATOR(CheckHasInstanceInst, TerminatorInst)
TERMINATOR(TryStartInst, TerminatorInst)

BEGIN_TERMINATOR(CompareBranchInst, TerminatorInst)
Expand Down
77 changes: 0 additions & 77 deletions include/hermes/IR/Instrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2319,83 +2319,6 @@ class GetNextPNameInst : public TerminatorInst {
}
};

class CheckHasInstanceInst : public TerminatorInst {
CheckHasInstanceInst(const CheckHasInstanceInst &) = delete;
void operator=(const CheckHasInstanceInst &) = delete;

public:
enum { ResultIdx, LeftIdx, RightIdx, OnTrueIdx, OnFalseIdx };

explicit CheckHasInstanceInst(
AllocStackInst *result,
Value *left,
Value *right,
BasicBlock *onTrue,
BasicBlock *onFalse)
: TerminatorInst(ValueKind::CheckHasInstanceInstKind) {
pushOperand(result);
pushOperand(left);
pushOperand(right);
pushOperand(onTrue);
pushOperand(onFalse);
}
explicit CheckHasInstanceInst(
const CheckHasInstanceInst *src,
llvh::ArrayRef<Value *> operands)
: TerminatorInst(src, operands) {}

static bool hasOutput() {
return false;
}

SideEffectKind getSideEffect() {
return SideEffectKind::None;
}

WordBitSet<> getChangedOperandsImpl() {
return {};
}

static bool classof(const Value *V) {
ValueKind kind = V->getKind();
return kind == ValueKind::CheckHasInstanceInstKind;
}

AllocStackInst *getResult() const {
return cast<AllocStackInst>(getOperand(ResultIdx));
}
Value *getLeft() const {
return getOperand(LeftIdx);
}
Value *getRight() const {
return getOperand(RightIdx);
}
BasicBlock *getOnTrueDest() const {
return cast<BasicBlock>(getOperand(OnTrueIdx));
}
BasicBlock *getOnFalseDest() const {
return cast<BasicBlock>(getOperand(OnFalseIdx));
}

unsigned getNumSuccessors() const {
return 2;
}
BasicBlock *getSuccessor(unsigned idx) const {
if (idx == 0)
return getOnTrueDest();
if (idx == 1)
return getOnFalseDest();
llvm_unreachable("CheckHasInstanceInst only have 2 successors!");
}
void setSuccessor(unsigned idx, BasicBlock *B) {
if (idx == 0)
return setOperand(B, OnTrueIdx);
if (idx == 1)
return setOperand(B, OnFalseIdx);
llvm_unreachable("CheckHasInstanceInst only have 2 successors!");
}
};

class TryStartInst : public TerminatorInst {
TryStartInst(const TryStartInst &) = delete;
void operator=(const TryStartInst &) = delete;
Expand Down
5 changes: 0 additions & 5 deletions lib/BCGen/HBC/ISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,11 +1167,6 @@ void HBCISel::generateGetNextPNameInst(
registerLongJump(loc, onSomeBlock);
}
}
void HBCISel::generateCheckHasInstanceInst(
CheckHasInstanceInst *Inst,
BasicBlock *next) {
llvm_unreachable("This instruction is not in use in HBC.");
}
void HBCISel::generateTryStartInst(TryStartInst *Inst, BasicBlock *next) {
// TryStartInst is the same as BranchInst in bytecode gen.
BasicBlock *destination = Inst->getTryBody();
Expand Down
3 changes: 0 additions & 3 deletions lib/BCGen/SH/SH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,6 @@ class InstrGen {
generateBasicBlockLabel(inst.getOnSomeDest(), os_, bbMap_);
os_ << ";\n";
}
void generateCheckHasInstanceInst(CheckHasInstanceInst &inst) {
hermes_fatal("This instruction is not in use in HBC.");
}
void generateTryStartInst(TryStartInst &inst) {
// TODO(T132354002): Properly understand the nesting of try blocks so we can
// reuse SHJmpBufs.
Expand Down
11 changes: 0 additions & 11 deletions lib/IR/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,6 @@ ThrowInst *IRBuilder::createThrowInst(Value *thrownValue) {
return TI;
}

CheckHasInstanceInst *IRBuilder::createCheckHasInstanceInst(
AllocStackInst *result,
Value *left,
Value *right,
BasicBlock *onTrue,
BasicBlock *onFalse) {
auto *TI = new CheckHasInstanceInst(result, left, right, onTrue, onFalse);
insert(TI);
return TI;
}

TryStartInst *IRBuilder::createTryStartInst(
BasicBlock *tryBodyBlock,
BasicBlock *catchTargetBlock) {
Expand Down
8 changes: 0 additions & 8 deletions lib/IR/IRVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ void Verifier::beforeVisitInstruction(const Instruction &Inst) {
Assert(
llvh::isa<LoadStackInst>(Inst) || llvh::isa<StoreStackInst>(Inst) ||
llvh::isa<CatchInst>(Inst) || llvh::isa<GetPNamesInst>(Inst) ||
llvh::isa<CheckHasInstanceInst>(Inst) ||
llvh::isa<GetNextPNameInst>(Inst) ||
llvh::isa<ResumeGeneratorInst>(Inst) ||
llvh::isa<IteratorBeginInst>(Inst) ||
Expand Down Expand Up @@ -730,13 +729,6 @@ void Verifier::visitSwitchImmInst(const hermes::SwitchImmInst &Inst) {
}
}

void Verifier::visitCheckHasInstanceInst(const CheckHasInstanceInst &Inst) {
Assert(isTerminator(&Inst), "CheckHasInstanceInst must be a terminator");
Assert(
Inst.getNumSuccessors() == 2,
"CheckHasInstanceInst should have 2 successors");
}

void Verifier::visitDebuggerInst(DebuggerInst const &Inst) {
// Nothing to verify at this point.
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Optimizer/Scalar/TypeInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,6 @@ class TypeInferenceImpl {
Type inferGetNextPNameInst(GetNextPNameInst *inst) {
return Type::createNoType();
}
Type inferCheckHasInstanceInst(CheckHasInstanceInst *inst) {
return Type::createNoType();
}
Type inferTryStartInst(TryStartInst *inst) {
return Type::createNoType();
}
Expand Down

0 comments on commit 2ffd972

Please sign in to comment.