[llvm-commits] [llvm] r52472 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Matthijs Kooijman matthijs at stdin.nl
Thu Jun 19 00:38:06 PDT 2008


Hi Owen,

> +  e.type = I->getType();
> +  e.firstVN = lookup_or_add(I->getOperand(0));
> +  e.secondVN = lookup_or_add(I->getOperand(1));
> +  e.thirdVN = 0;
> +  e.function = 0;
> +  e.opcode = Expression::INSERTVALUE;
> +  
> +  for (InsertValueInst::op_iterator OI = I->op_begin()+2,
> +       OE = I->op_end(); OI != OE; ++OI)
> +    e.varargs.push_back(lookup_or_add(I));
What is this last loop supposed to do? It seems like you're trying to iterate
the index arguments of the instruction, but those are not operands (ie, not
Value*s). If you want to loop them, you should use idx_begin/end instead.

Also, you're looking up "I" in the loop body, ignoring the OI iterator. Is
that intentional?

> +  for (InsertValueInst::op_iterator OI = I->op_begin()+2,
> +       OE = I->op_end(); OI != OE; ++OI)
> +    e.varargs.push_back(lookup_or_add(I));

The same question goes for ExtractValue here. Additionally, you'r using
op_begin() + 2, while extractvalue has only one operand. I think this might be
causing the crash Evan reported.

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080619/1494e321/attachment.sig>


More information about the llvm-commits mailing list