From 21f7cf4057b75ac3bc46597415499dd0fc214e97 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 22 May 2020 09:12:06 -0400 Subject: [PATCH] [SLP] fix verification check for valid IR This is a fix for PR45965 - https://bugs.llvm.org/show_bug.cgi?id=45965 - which was left out of D80106 because of a test failure. SLP does its own mini-CSE after potentially creating redundant instructions, so we need to wait for that to complete before running the verifier. Otherwise, we will see a test failure for test/Transforms/SLPVectorizer/X86/crash_vectorizeTree.ll (not changed here) because a phi temporarily has identical but different incoming values for the same incoming block. A related, but independent, test that would have been altered here was fixed with: rG880df55 The test was escaping verification in SLP without this change because we were not running verifyFunction() unless SLP actually changed the IR. Differential Revision: https://reviews.llvm.org/D80401 --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 26d9705..5627fa4 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2365,6 +2365,7 @@ BoUpSLP::~BoUpSLP() { "trying to erase instruction with users."); Pair.getFirst()->eraseFromParent(); } + assert(!verifyFunction(*F, &dbgs())); } void BoUpSLP::eraseInstructions(ArrayRef AV) { @@ -5743,7 +5744,6 @@ bool SLPVectorizerPass::runImpl(Function &F, ScalarEvolution *SE_, if (Changed) { R.optimizeGatherSequence(); LLVM_DEBUG(dbgs() << "SLP: vectorized \"" << F.getName() << "\"\n"); - LLVM_DEBUG(verifyFunction(F)); } return Changed; } -- 2.7.4