Since we have a known miscompile danger here, I'll propose a patch for people to look at.
This is the most basic (yet still incomplete) solution that I could come up with for the miscompiles in:
https://bugs.llvm.org/show_bug.cgi?id=33695
https://bugs.llvm.org/show_bug.cgi?id=34037
As discussed in PR33695, we need to do more than this, and there are probably better implementations, but this is a safe first step to close the hole?
I think this is better than the opcode list I suggested. Why don't we just do this instead? Isn't it just something like this?
auto isExternallyVisible = [&](Instruction *I) { // Any value we're trivializing should be an integer value, and moreover, any conversion between an integer value and a non-integer value should demand all of the bits, which will cause us to stop looking down the use/def chain, so we should only see integer-typed instructions here. assert(I->getType()->isIntegerTy() && "Trivializing a non-integer value?"); return DB.getDemandedBits(I).isAllOnesValue(); }