@@ -2261,17 +2261,12 @@ struct DSEState {
22612261 bool eliminateDeadDefs (const MemoryDefWrapper &KillingDefWrapper);
22622262};
22632263
2264- // Return true if "Arg" is function local and isn't captured before "CB" or
2265- // if "Arg" is GEP whose base pointer is function local and isn't captured
2266- // before "CB".
2267- bool IsFuncLocalAndNotCaptured (Value *Arg, const CallBase *CB,
2264+ // Return true if "Arg" is function local and isn't captured before "CB".
2265+ bool isFuncLocalAndNotCaptured (Value *Arg, const CallBase *CB,
22682266 EarliestEscapeAnalysis &EA) {
2269- if (isIdentifiedFunctionLocal (Arg))
2270- return EA.isNotCapturedBefore (Arg, CB, /* OrAt*/ true );
2271- const auto *GEP = dyn_cast<GetElementPtrInst>(Arg);
2272- if (GEP && isIdentifiedFunctionLocal (GEP->getPointerOperand ()))
2273- return EA.isNotCapturedBefore (GEP->getPointerOperand (), CB, /* OrAt*/ true );
2274- return false ;
2267+ const Value *UnderlyingObj = getUnderlyingObject (Arg);
2268+ return isIdentifiedFunctionLocal (UnderlyingObj) &&
2269+ EA.isNotCapturedBefore (UnderlyingObj, CB, /* OrAt*/ true );
22752270}
22762271
22772272SmallVector<MemoryLocation, 1 >
@@ -2292,7 +2287,7 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {
22922287 // Check whether "CurArg" could alias with global variables. We require
22932288 // either it's function local and isn't captured before or the "CB" only
22942289 // accesses arg or inaccessible mem.
2295- if (!Inits.empty () && !IsFuncLocalAndNotCaptured (CurArg, CB, EA) &&
2290+ if (!Inits.empty () && !isFuncLocalAndNotCaptured (CurArg, CB, EA) &&
22962291 !CB->onlyAccessesInaccessibleMemOrArgMem ())
22972292 Inits = ConstantRangeList ();
22982293
0 commit comments