[PATCH] D81943: [SROA] Teach SROA to perform no-op pointer conversion.
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 16 15:56:24 PDT 2020
arsenm added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/SROA.cpp:1706
if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
- return cast<PointerType>(NewTy)->getPointerAddressSpace() ==
- cast<PointerType>(OldTy)->getPointerAddressSpace();
+ unsigned OldAS = cast<PointerType>(OldTy)->getPointerAddressSpace();
+ unsigned NewAS = cast<PointerType>(NewTy)->getPointerAddressSpace();
----------------
cast<PointerType>->getPointerAddressSpace is redundant. You can drop the pionter in the getter. Also, in this case I would probably prefer dyn_cast and check the pointer since this is immediately after an isPointerTy check
================
Comment at: llvm/lib/Transforms/Scalar/SROA.cpp:1780
+ unsigned NewAS = NewTy->getPointerAddressSpace();
+ // Generate pair of ptrtoint/inttoptr.
+ if (OldAS != NewAS) {
----------------
Isn't there a create-noop or create reinterpret cast somewhere?
This also probably needs more comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81943/new/
https://reviews.llvm.org/D81943
More information about the llvm-commits
mailing list