From 0c3518e84b668975df03ac8b9620d7bf181bd349 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 4 May 2016 15:40:57 +0000 Subject: [SimplifyCFG] isSafeToSpeculateStore now ignores debug info This patch fixes PR27615. @llvm.dbg.value instructions no longer count towards the maximum number of instructions to look back at in the instruction list when searching for a store instruction. This should make the output consistent between debug and non-debug build. Patch by Henric Karlsson ! Differential Revision: http://reviews.llvm.org/D19912 llvm-svn: 268512 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms/Utils') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 6ac039d8a1a..6d347d624e2 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1448,10 +1448,14 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB, Value *StorePtr = StoreToHoist->getPointerOperand(); // Look for a store to the same pointer in BrBB. - unsigned MaxNumInstToLookAt = 10; + unsigned MaxNumInstToLookAt = 9; for (BasicBlock::reverse_iterator RI = BrBB->rbegin(), - RE = BrBB->rend(); RI != RE && (--MaxNumInstToLookAt); ++RI) { + RE = BrBB->rend(); RI != RE && MaxNumInstToLookAt; ++RI) { Instruction *CurI = &*RI; + // Skip debug info. + if (isa(CurI)) + continue; + --MaxNumInstToLookAt; // Could be calling an instruction that effects memory like free(). if (CurI->mayHaveSideEffects() && !isa(CurI)) -- cgit v1.2.3