Skip to content

Commit d202bc7

Browse files
committed
Revert "Revert "InstSimplify: Remove null parent checks""
This reverts commit 935c8b6. Going to fix forward size regression instead due to more dependent patches needing to be reverted otherwise.
1 parent 3e39cfe commit d202bc7

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ static bool valueDominatesPHI(Value *V, PHINode *P, const DominatorTree *DT) {
218218
// Arguments and constants dominate all instructions.
219219
return true;
220220

221-
// If we are processing instructions (and/or basic blocks) that have not been
222-
// fully added to a function, the parent nodes may still be null. Simply
223-
// return the conservative answer in these cases.
224-
if (!I->getParent() || !P->getParent() || !I->getFunction())
225-
return false;
226-
227221
// If we have a DominatorTree then do a precise test.
228222
if (DT)
229223
return DT->dominates(I, P);
@@ -2638,7 +2632,7 @@ static bool isAllocDisjoint(const Value *V) {
26382632
// that might be resolve lazily to symbols in another dynamically-loaded
26392633
// library (and, thus, could be malloc'ed by the implementation).
26402634
if (const AllocaInst *AI = dyn_cast<AllocaInst>(V))
2641-
return AI->getParent() && AI->getFunction() && AI->isStaticAlloca();
2635+
return AI->isStaticAlloca();
26422636
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V))
26432637
return (GV->hasLocalLinkage() || GV->hasHiddenVisibility() ||
26442638
GV->hasProtectedVisibility() || GV->hasGlobalUnnamedAddr()) &&
@@ -3669,7 +3663,7 @@ static Value *simplifyICmpWithDominatingAssume(CmpInst::Predicate Predicate,
36693663
Value *LHS, Value *RHS,
36703664
const SimplifyQuery &Q) {
36713665
// Gracefully handle instructions that have not been inserted yet.
3672-
if (!Q.AC || !Q.CxtI || !Q.CxtI->getParent())
3666+
if (!Q.AC || !Q.CxtI)
36733667
return nullptr;
36743668

36753669
for (Value *AssumeBaseOp : {LHS, RHS}) {
@@ -6475,9 +6469,6 @@ static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
64756469
if (!NumOperands) {
64766470
switch (IID) {
64776471
case Intrinsic::vscale: {
6478-
// Call may not be inserted into the IR yet at point of calling simplify.
6479-
if (!Call->getParent() || !Call->getParent()->getParent())
6480-
return nullptr;
64816472
auto Attr = Call->getFunction()->getFnAttribute(Attribute::VScaleRange);
64826473
if (!Attr.isValid())
64836474
return nullptr;
@@ -6925,10 +6916,7 @@ static bool replaceAndRecursivelySimplifyImpl(
69256916
// Replace the instruction with its simplified value.
69266917
I->replaceAllUsesWith(SimpleV);
69276918

6928-
// Gracefully handle edge cases where the instruction is not wired into any
6929-
// parent block.
6930-
if (I->getParent() && !I->isEHPad() && !I->isTerminator() &&
6931-
!I->mayHaveSideEffects())
6919+
if (!I->isEHPad() && !I->isTerminator() && !I->mayHaveSideEffects())
69326920
I->eraseFromParent();
69336921
} else {
69346922
Worklist.insert(I);
@@ -6957,10 +6945,7 @@ static bool replaceAndRecursivelySimplifyImpl(
69576945
// Replace the instruction with its simplified value.
69586946
I->replaceAllUsesWith(SimpleV);
69596947

6960-
// Gracefully handle edge cases where the instruction is not wired into any
6961-
// parent block.
6962-
if (I->getParent() && !I->isEHPad() && !I->isTerminator() &&
6963-
!I->mayHaveSideEffects())
6948+
if (!I->isEHPad() && !I->isTerminator() && !I->mayHaveSideEffects())
69646949
I->eraseFromParent();
69656950
}
69666951
return Simplified;

0 commit comments

Comments
 (0)