================
@@ -3007,18 +2999,8 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
}
case CK_PointerToIntegral: {
assert(!DestTy->isBooleanType() && "bool should use PointerToBool");
- auto *PtrExpr = Visit(E);
-
- if (CGF.CGM.getCodeGenOpts().StrictVTablePointers) {
- const QualType SrcType = E->getType();
-
- // Casting to integer requires stripping dynamic information as it does
- // not carries it.
----------------
nikic wrote:
For the specific case of casts to integers, there is some remaining risk,
because integers don't have provenance, so replacements based on a comparison
like `(uintptr_t)a == (uintptr_t)b` is still possible. The replacement itself
is legal, but because we still (incorrectly) fold away `inttoptr(ptrtoint(x))`
it could result in an overall miscompile.
Though this is mitigated by `(uintptr_t)a == (uintptr_t)b` being folded to `a
== b` by the optimizer (which then does have the provenance restriction), and
by Clang introducing launder.invariant.group calls when casting from integer
back to pointer. So I think that overall there shouldn't be practical issues
here.
https://github.com/llvm/llvm-project/pull/225072
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits