Skip to content

Commit 5edbc30

Browse files
committed
Address 2nd comments from nocchijiang
1 parent dc6f20e commit 5edbc30

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

llvm/lib/CodeGen/GlobalMergeFunctions.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool isEligibleFunction(Function *F) {
102102
return true;
103103
}
104104

105-
static bool isEligibleInstrunctionForConstantSharing(const Instruction *I) {
105+
static bool isEligibleInstructionForConstantSharing(const Instruction *I) {
106106
switch (I->getOpcode()) {
107107
case Instruction::Load:
108108
case Instruction::Store:
@@ -114,10 +114,15 @@ static bool isEligibleInstrunctionForConstantSharing(const Instruction *I) {
114114
}
115115
}
116116

117+
// This function takes an instruction, \p I, and an operand index, \p OpIdx.
118+
// It returns true if the operand should be ignored in the hash computation.
119+
// If \p OpIdx is out of range based on the other instruction context, it cannot
120+
// be ignored.
117121
static bool ignoreOp(const Instruction *I, unsigned OpIdx) {
118-
assert(OpIdx < I->getNumOperands() && "Invalid operand index");
122+
if (OpIdx >= I->getNumOperands())
123+
return false;
119124

120-
if (!isEligibleInstrunctionForConstantSharing(I))
125+
if (!isEligibleInstructionForConstantSharing(I))
121126
return false;
122127

123128
if (!isa<Constant>(I->getOperand(OpIdx)))

0 commit comments

Comments
 (0)