Skip to content

Commit

Permalink
Revert "[ObjC][ARC] Check the basic block size before calling Dominat…
Browse files Browse the repository at this point in the history
…orTree::dominate"

This reverts commit 5c3117b

This should not be necessary after
7593a48, and Florian Hahn has confirmed
that the problem no longer reproduces with this patch.

I happened to notice this code because the FIXME talks about
OrderedBasicBlock.

Reviewed By: fhahn, dexonsmith

Differential Revision: https://reviews.llvm.org/D76075
  • Loading branch information
rnk committed Mar 13, 2020
1 parent 05c0d34 commit 478b06e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
35 changes: 1 addition & 34 deletions llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
Expand Up @@ -47,10 +47,6 @@ using namespace llvm::objcarc;
STATISTIC(NumPeeps, "Number of calls peephole-optimized");
STATISTIC(NumStoreStrongs, "Number objc_storeStrong calls formed");

static cl::opt<unsigned> MaxBBSize("arc-contract-max-bb-size", cl::Hidden,
cl::desc("Maximum basic block size to discover the dominance relation of "
"two instructions in the same basic block"), cl::init(65535));

//===----------------------------------------------------------------------===//
// Declarations
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -580,23 +576,6 @@ bool ObjCARCContract::runOnFunction(Function &F) {
SmallPtrSet<Instruction *, 4> DependingInstructions;
SmallPtrSet<const BasicBlock *, 4> Visited;

// Cache the basic block size.
DenseMap<const BasicBlock *, unsigned> BBSizeMap;

// A lambda that lazily computes the size of a basic block and determines
// whether the size exceeds MaxBBSize.
auto IsLargeBB = [&](const BasicBlock *BB) {
unsigned BBSize;
auto I = BBSizeMap.find(BB);

if (I != BBSizeMap.end())
BBSize = I->second;
else
BBSize = BBSizeMap[BB] = BB->size();

return BBSize > MaxBBSize;
};

for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E;) {
Instruction *Inst = &*I++;

Expand All @@ -614,7 +593,7 @@ bool ObjCARCContract::runOnFunction(Function &F) {
// and such; to do the replacement, the argument must have type i8*.

// Function for replacing uses of Arg dominated by Inst.
auto ReplaceArgUses = [Inst, IsLargeBB, this](Value *Arg) {
auto ReplaceArgUses = [Inst, this](Value *Arg) {
// If we're compiling bugpointed code, don't get in trouble.
if (!isa<Instruction>(Arg) && !isa<Argument>(Arg))
return;
Expand All @@ -626,17 +605,6 @@ bool ObjCARCContract::runOnFunction(Function &F) {
Use &U = *UI++;
unsigned OperandNo = U.getOperandNo();

// Don't replace the uses if Inst and the user belong to the same basic
// block and the size of the basic block is large. We don't want to call
// DominatorTree::dominate in that case. We can remove this check if we
// can use OrderedBasicBlock to compute the dominance relation between
// two instructions, but that's not currently possible since it doesn't
// recompute the instruction ordering when new instructions are inserted
// to the basic block.
if (Inst->getParent() == cast<Instruction>(U.getUser())->getParent() &&
IsLargeBB(Inst->getParent()))
continue;

// If the call's return value dominates a use of the call's argument
// value, rewrite the use to use the return value. We check for
// reachability here because an unreachable call is considered to
Expand Down Expand Up @@ -689,7 +657,6 @@ bool ObjCARCContract::runOnFunction(Function &F) {
}
};


Value *Arg = cast<CallInst>(Inst)->getArgOperand(0);
Value *OrigArg = Arg;

Expand Down
17 changes: 0 additions & 17 deletions llvm/test/Transforms/ObjCARC/contract-max-bb-size.ll

This file was deleted.

0 comments on commit 478b06e

Please sign in to comment.