From: Austin Kerbow Date: Thu, 12 Sep 2019 19:12:21 +0000 (+0000) Subject: AMDGPU: Fix bug in r371671 on some builds. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e517ad32da7946c5a5827e6cff5a0334ea6dfbc2;p=llvm AMDGPU: Fix bug in r371671 on some builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371761 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AMDGPU/SIFixSGPRCopies.cpp b/lib/Target/AMDGPU/SIFixSGPRCopies.cpp index 1e95cee7bf8..dad9fedff25 100644 --- a/lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ b/lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -589,11 +589,14 @@ static bool hoistAndMergeSGPRInits(unsigned Reg, // Remove initializations that were merged into another. for (auto &Init : Inits) { auto &Defs = Init.second; - for (auto I = Defs.begin(); I != Defs.end(); ++I) + auto I = Defs.begin(); + while (I != Defs.end()) { if (MergedInstrs.count(*I)) { (*I)->eraseFromParent(); I = Defs.erase(I); - } + } else + ++I; + } } // Try to schedule SGPR initializations as early as possible in the MBB.