While studying your patch, I have a question, so I’m posting my question here. I hope it’s not rude.
I’m curious why you didn’t implement what you patched inside canCreateUndefOrPoison. I’m asking a question because I think it will be helpful in studying.
canCreateUndefOrPoison
case Intrinsic::abs:
if (cast<ConstantInt>(II->getArgOperand(1))->isNullValue())
return false;
break;
Hi,
IIRC I tried doing it in canCreateUndefOrPoison first, but there we don’t have knowledge (or if we do, I didn’t find how to access it) of whether the first argument is never signed min or not.
@nikic kindly helped me with this patch as I was unfamiliar with this part of LLVM. Maybe they can give more detail?
canCreateUndefOrPoison() works on the original operands of the instruction, while here we only know it is not poison when looking at the replaced operands. To handle this in canCreateUndefOrPoison(), it would be necessary to pass in the instruction operands to that function.