diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-09-24 21:01:20 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-09-24 21:01:20 +0000 |
commit | 11c06ea55a060d5460f716b00ca593e5dd829b17 (patch) | |
tree | 5e1319ee98cdd3e45f98ec4f22b2c5eefafcd0a9 | |
parent | b1b208a1f514ccb90b5afba0af49d6aa39dee21b (diff) | |
download | bcm5719-llvm-11c06ea55a060d5460f716b00ca593e5dd829b17.tar.gz bcm5719-llvm-11c06ea55a060d5460f716b00ca593e5dd829b17.zip |
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.
llvm-svn: 282338
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index a6907b56cf4..ed5063cdf1a 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -53,6 +53,11 @@ using namespace llvm::objcarc; /// \brief This is similar to GetRCIdentityRoot but it stops as soon /// as it finds a value with multiple uses. static const Value *FindSingleUseIdentifiedObject(const Value *Arg) { + // ConstantData (like ConstantPointerNull and UndefValue) is used across + // modules. It's never a single-use value. + if (isa<ConstantData>(Arg)) + return nullptr; + if (Arg->hasOneUse()) { if (const BitCastInst *BC = dyn_cast<BitCastInst>(Arg)) return FindSingleUseIdentifiedObject(BC->getOperand(0)); @@ -644,6 +649,12 @@ void ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, ARCInstKind &Class) { // Check for a return of the pointer value. const Value *Ptr = GetArgRCIdentityRoot(AutoreleaseRV); + + // If the argument is ConstantPointerNull or UndefValue, its other users + // aren't actually interesting to look at. + if (isa<ConstantData>(Ptr)) + return; + SmallVector<const Value *, 2> Users; Users.push_back(Ptr); do { |