[PATCH] D109114: [GlobalDCE] In VFE, replace the whole 'sub' expression of unused relative-pointer-based vtable slots
Kuba (Brecka) Mracek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 17 21:02:49 PDT 2021
kubamracek added a comment.
> Can the code here (matching ptrtoint/sub) be unified with the code that matches it in getPointerAtOffset, so those patterns won't diverge?
Suggestions how to do that? The code in getPointerAtOffset is quite different, because is recurses *down into* the expression, whereas here we need to walk up by looking at users. I could move the code to be next to each other, would that be good enough?
> the assert here seems dangerous, as nothing guards against PtrExpr having multiple users, right? PtrExpr having multiple users is valid IR, so we should probably handle this gracefully.
I believe the assert actually holds. At this point, we know that F is *only* referenced from vtables (either one or more) and nothing else (otherwise it wouldn't be in DeadFunctions). F can have multiple users, if there's multiple vtables, but each use is a Constant/ConstantExpr in a vtable. Unless I misunderstand something, I believe in a ConstantExpr like `trunc(sub(ptrtoint(x),ptrtoint(y))` all the nodes always have a unique single user and that's the parent ConstantExpr. Therefore the ptrtoint here, which must be in the vtable expression, must always have a single user.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109114/new/
https://reviews.llvm.org/D109114
More information about the llvm-commits
mailing list