@@ -2514,8 +2514,8 @@ void coro::salvageDebugInfo(
2514
2514
bool OutermostLoad = true ;
2515
2515
Value *Storage = DVI->getVariableLocationOp (0 );
2516
2516
Value *OriginalStorage = Storage;
2517
- while (Storage) {
2518
- if (auto *LdInst = dyn_cast<LoadInst>(Storage )) {
2517
+ while (auto *Inst = dyn_cast<Instruction>( Storage) ) {
2518
+ if (auto *LdInst = dyn_cast<LoadInst>(Inst )) {
2519
2519
Storage = LdInst->getOperand (0 );
2520
2520
// FIXME: This is a heuristic that works around the fact that
2521
2521
// LLVM IR debug intrinsics cannot yet distinguish between
@@ -2526,41 +2526,36 @@ void coro::salvageDebugInfo(
2526
2526
if (!OutermostLoad)
2527
2527
Expr = DIExpression::prepend (Expr, DIExpression::DerefBefore);
2528
2528
OutermostLoad = false ;
2529
- } else if (auto *StInst = dyn_cast<StoreInst>(Storage )) {
2529
+ } else if (auto *StInst = dyn_cast<StoreInst>(Inst )) {
2530
2530
Storage = StInst->getOperand (0 );
2531
- } else if (auto *GEPInst = dyn_cast<GetElementPtrInst>(Storage)) {
2532
- SmallVector<uint64_t , 16 > Ops;
2533
- SmallVector<Value *, 0 > AdditionalValues;
2534
- Storage = llvm::salvageDebugInfoImpl (
2535
- *GEPInst, Expr ? Expr->getNumLocationOperands () : 0 , Ops,
2536
- AdditionalValues);
2537
- if (!Storage)
2538
- break ;
2539
- // Debug declares cannot currently handle additional location
2540
- // operands.
2541
- if (!AdditionalValues.empty ())
2542
- break ;
2543
- Expr = DIExpression::appendOpsToArg (Expr, Ops, 0 , /* StackValue*/ false );
2544
- } else if (auto *BCInst = dyn_cast<llvm::BitCastInst>(Storage))
2545
- Storage = BCInst->getOperand (0 );
2546
- } else if (auto *I2PInst = dyn_cast<llvm::IntToPtrInst>(Storage)) {
2531
+ } else if (auto *I2PInst = dyn_cast<llvm::IntToPtrInst>(Inst)) {
2547
2532
Storage = I2PInst->getOperand (0 );
2548
- } else if (auto *P2IInst = dyn_cast<llvm::PtrToIntInst>(Storage )) {
2533
+ } else if (auto *P2IInst = dyn_cast<llvm::PtrToIntInst>(Inst )) {
2549
2534
Storage = P2IInst->getOperand (0 );
2550
- } else if (auto *IInst = dyn_cast<llvm::IntrinsicInst>(Storage )) {
2535
+ } else if (auto *IInst = dyn_cast<llvm::IntrinsicInst>(Inst )) {
2551
2536
if (IInst->getIntrinsicID () == Intrinsic::ptrauth_auth)
2552
2537
Storage = IInst->getArgOperand (0 );
2553
2538
else
2554
2539
break ;
2555
- } else if (auto *Phi = dyn_cast<PHINode>(Storage )) {
2540
+ } else if (auto *Phi = dyn_cast<PHINode>(Inst )) {
2556
2541
if (Phi->getNumIncomingValues () != 1 )
2557
2542
return ;
2558
2543
Storage = Phi->getIncomingValue (0 );
2559
- } else
2560
- break ;
2544
+ } else {
2545
+ SmallVector<uint64_t , 16 > Ops;
2546
+ SmallVector<Value *, 0 > AdditionalValues;
2547
+ Value *Op = llvm::salvageDebugInfoImpl (
2548
+ *Inst, Expr ? Expr->getNumLocationOperands () : 0 , Ops,
2549
+ AdditionalValues);
2550
+ if (!Op || !AdditionalValues.empty ()) {
2551
+ // If salvaging failed or salvaging produced more than one location
2552
+ // operand, give up.
2553
+ break ;
2554
+ }
2555
+ Storage = Op;
2556
+ Expr = DIExpression::appendOpsToArg (Expr, Ops, 0 , /* StackValue*/ false );
2557
+ }
2561
2558
}
2562
- if (!Storage)
2563
- return ;
2564
2559
2565
2560
// Store a pointer to the coroutine frame object in an alloca so it
2566
2561
// is available throughout the function when producing unoptimized
0 commit comments