@@ -1529,23 +1529,26 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr,
15291529 }
15301530 }
15311531
1532+ if (auto *II = dyn_cast<IntrinsicInst>(DepInst)) {
1533+ auto *LifetimePtr = II->getOperand (1 );
1534+ if (II->getIntrinsicID () == Intrinsic::lifetime_start &&
1535+ (LoadPtr == lookupOperandLeader (LifetimePtr) ||
1536+ AA->isMustAlias (LoadPtr, LifetimePtr)))
1537+ return createConstantExpression (UndefValue::get (LoadType));
1538+ }
1539+
15321540 // All of the below are only true if the loaded pointer is produced
15331541 // by the dependent instruction.
1534- if (LoadPtr != lookupOperandLeader (DepInst) &&
1535- DepInst->getType ()->isPointerTy () && !AA->isMustAlias (LoadPtr, DepInst))
1542+ if (!DepInst->getType ()->isPointerTy () ||
1543+ (LoadPtr != lookupOperandLeader (DepInst) &&
1544+ !AA->isMustAlias (LoadPtr, DepInst)))
15361545 return nullptr ;
15371546 // If this load really doesn't depend on anything, then we must be loading an
15381547 // undef value. This can happen when loading for a fresh allocation with no
15391548 // intervening stores, for example. Note that this is only true in the case
15401549 // that the result of the allocation is pointer equal to the load ptr.
15411550 if (isa<AllocaInst>(DepInst)) {
15421551 return createConstantExpression (UndefValue::get (LoadType));
1543- }
1544- // If this load occurs either right after a lifetime begin,
1545- // then the loaded value is undefined.
1546- else if (auto *II = dyn_cast<IntrinsicInst>(DepInst)) {
1547- if (II->getIntrinsicID () == Intrinsic::lifetime_start)
1548- return createConstantExpression (UndefValue::get (LoadType));
15491552 } else if (auto *InitVal =
15501553 getInitialValueOfAllocation (DepInst, TLI, LoadType))
15511554 return createConstantExpression (InitVal);
0 commit comments