Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit affe799

Browse files
committed
ObjCARC: Don't look at users of ConstantData
Stop looking at users of UndefValue and ConstantPointerNull in the objective C ARC optimizers. The other users aren't actually interesting, since they're not pointing at a particular object. I imagine these calls could be optimized through -instcombine... maybe they already are? These early returns will be required at some point in the future, with a WIP patch that asserts when someone accesses a use-list on ConstantData. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282338 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5cb2954 commit affe799

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/Transforms/ObjCARC/ObjCARCOpts.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ using namespace llvm::objcarc;
5353
/// \brief This is similar to GetRCIdentityRoot but it stops as soon
5454
/// as it finds a value with multiple uses.
5555
static const Value *FindSingleUseIdentifiedObject(const Value *Arg) {
56+
// ConstantData (like ConstantPointerNull and UndefValue) is used across
57+
// modules. It's never a single-use value.
58+
if (isa<ConstantData>(Arg))
59+
return nullptr;
60+
5661
if (Arg->hasOneUse()) {
5762
if (const BitCastInst *BC = dyn_cast<BitCastInst>(Arg))
5863
return FindSingleUseIdentifiedObject(BC->getOperand(0));
@@ -644,6 +649,12 @@ void ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F,
644649
ARCInstKind &Class) {
645650
// Check for a return of the pointer value.
646651
const Value *Ptr = GetArgRCIdentityRoot(AutoreleaseRV);
652+
653+
// If the argument is ConstantPointerNull or UndefValue, its other users
654+
// aren't actually interesting to look at.
655+
if (isa<ConstantData>(Ptr))
656+
return;
657+
647658
SmallVector<const Value *, 2> Users;
648659
Users.push_back(Ptr);
649660
do {

0 commit comments

Comments
 (0)