From 5c7bf1a75652ef73968b3737d44ea4bd2fe49673 Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Tue, 9 Oct 2018 23:10:56 +0000 Subject: [PATCH] [X86] Fix sanitizer bot failure from 344085 Fix the memory issue exposed by sanitizer. llvm-svn: 344092 --- llvm/lib/Target/X86/X86CondBrFolding.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/X86CondBrFolding.cpp b/llvm/lib/Target/X86/X86CondBrFolding.cpp index 9a5ae70..8b9ef20 100644 --- a/llvm/lib/Target/X86/X86CondBrFolding.cpp +++ b/llvm/lib/Target/X86/X86CondBrFolding.cpp @@ -424,8 +424,9 @@ bool X86CondBrFolding::optimize() { } NumFixedCondBrs += RemoveList.size(); for (auto MBBI : RemoveList) { - for (auto *Succ : MBBI->successors()) - MBBI->removeSuccessor(Succ); + while (!MBBI->succ_empty()) + MBBI->removeSuccessor(MBBI->succ_end() - 1); + MBBI->eraseFromParent(); } -- 2.7.4