[coro][nfc] Use Load/Store instruction APIs
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>
Mon, 17 Apr 2023 21:17:04 +0000 (17:17 -0400)
committerFelipe de Azevedo Piovezan <fpiovezan@apple.com>
Tue, 18 Apr 2023 13:07:41 +0000 (09:07 -0400)
Instead of hard-coding operand indices, it is cleaner to use the APIs
provided by the Load/Store Inst classes.

Differential Revision: https://reviews.llvm.org/D148571

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

index 90fe01a..8c130be 100644 (file)
@@ -2832,7 +2832,7 @@ void coro::salvageDebugInfo(
 
   while (auto *Inst = dyn_cast_or_null<Instruction>(Storage)) {
     if (auto *LdInst = dyn_cast<LoadInst>(Inst)) {
-      Storage = LdInst->getOperand(0);
+      Storage = LdInst->getPointerOperand();
       // FIXME: This is a heuristic that works around the fact that
       // LLVM IR debug intrinsics cannot yet distinguish between
       // memory and value locations: Because a dbg.declare(alloca) is
@@ -2842,7 +2842,7 @@ void coro::salvageDebugInfo(
       if (!SkipOutermostLoad)
         Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
     } else if (auto *StInst = dyn_cast<StoreInst>(Inst)) {
-      Storage = StInst->getOperand(0);
+      Storage = StInst->getValueOperand();
     } else {
       SmallVector<uint64_t, 16> Ops;
       SmallVector<Value *, 0> AdditionalValues;