@@ -1529,23 +1529,26 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr,
1529
1529
}
1530
1530
}
1531
1531
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
+
1532
1540
// All of the below are only true if the loaded pointer is produced
1533
1541
// 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)))
1536
1545
return nullptr ;
1537
1546
// If this load really doesn't depend on anything, then we must be loading an
1538
1547
// undef value. This can happen when loading for a fresh allocation with no
1539
1548
// intervening stores, for example. Note that this is only true in the case
1540
1549
// that the result of the allocation is pointer equal to the load ptr.
1541
1550
if (isa<AllocaInst>(DepInst)) {
1542
1551
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));
1549
1552
} else if (auto *InitVal =
1550
1553
getInitialValueOfAllocation (DepInst, TLI, LoadType))
1551
1554
return createConstantExpression (InitVal);
0 commit comments