[llvm] r187646 - Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.

Chandler Carruth chandlerc at google.com
Fri Aug 2 02:10:48 PDT 2013


It does with ASan IIRC. THere is a thread about this on the mailing list
where Alexey reported the bug.


On Fri, Aug 2, 2013 at 1:31 AM, Duncan Sands <duncan.sands at gmail.com> wrote:

> Hi Alexey,
>
>
> On 02/08/13 10:06, Alexey Samsonov wrote:
>
>> Author: samsonov
>> Date: Fri Aug  2 03:06:43 2013
>> New Revision: 187646
>>
>> URL: http://llvm.org/viewvc/llvm-**project?rev=187646&view=rev<http://llvm.org/viewvc/llvm-project?rev=187646&view=rev>
>> Log:
>> Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.
>>
>
> does this bug fire on some testcases that are already in the regression
> test
> suite (for example if built with expensive checks enabled)?
>
> Ciao, Duncan.
>
>
>
>> Modified:
>>      llvm/trunk/lib/Transforms/**Utils/SimplifyCFG.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/**Utils/SimplifyCFG.cpp
>> URL: http://llvm.org/viewvc/llvm-**project/llvm/trunk/lib/**
>> Transforms/Utils/SimplifyCFG.**cpp?rev=187646&r1=187645&r2=**
>> 187646&view=diff<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=187646&r1=187645&r2=187646&view=diff>
>> ==============================**==============================**
>> ==================
>> --- llvm/trunk/lib/Transforms/**Utils/SimplifyCFG.cpp (original)
>> +++ llvm/trunk/lib/Transforms/**Utils/SimplifyCFG.cpp Fri Aug  2
>> 03:06:43 2013
>> @@ -4290,7 +4290,8 @@ bool SimplifyCFGOpt::**SimplifyParallelAnd
>>     // Do the transformation.
>>     BasicBlock *CB;
>>     bool Iteration = true;
>> -  BasicBlock::iterator ItOld = Builder.GetInsertPoint();
>> +  BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
>> +  BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
>>     BranchInst *PBI = dyn_cast<BranchInst>(**
>> FirstCondBlock->getTerminator(**));
>>     Value *PC = PBI->getCondition();
>>     do {
>> @@ -4319,8 +4320,8 @@ bool SimplifyCFGOpt::**SimplifyParallelAnd
>>       // make CB unreachable and let downstream to delete the block.
>>       new UnreachableInst(CB->**getContext(), CB);
>>     } while (Iteration);
>> -
>> -  Builder.SetInsertPoint(ItOld);
>> +  if (SaveInsertBB)
>> +    Builder.SetInsertPoint(**SaveInsertBB, SaveInsertPt);
>>     DEBUG(dbgs() << "Use parallel and/or in:\n" << *FirstCondBlock);
>>     return true;
>>   }
>> @@ -4454,11 +4455,13 @@ bool SimplifyCFGOpt::MergeIfRegion(**Basic
>>     FirstEntryBlock->getInstList()**.splice(FirstEntryBlock->end()**,
>> SecondEntryBlock->getInstList(**));
>>     BranchInst *PBI = dyn_cast<BranchInst>(**FirstEntryBlock->**
>> getTerminator());
>>     Value *CC = PBI->getCondition();
>> -  BasicBlock::iterator ItOld = Builder.GetInsertPoint();
>> +  BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
>> +  BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
>>     Builder.SetInsertPoint(PBI);
>>     Value *NC = Builder.CreateOr(CInst1, CC);
>>     PBI->replaceUsesOfWith(CC, NC);
>> -  Builder.SetInsertPoint(ItOld);
>> +  if (SaveInsertBB)
>> +    Builder.SetInsertPoint(**SaveInsertBB, SaveInsertPt);
>>
>>     // Remove IfTrue1
>>     if (IfTrue1 != FirstEntryBlock) {
>>
>>
>> ______________________________**_________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>>
>>
> ______________________________**_________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130802/8134bc23/attachment.html>


More information about the llvm-commits mailing list