[llvm-commits] [llvm] r128782 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Utils/Local.cpp test/Transforms/JumpThreading/2011-04-02-SimplifyDeadBlock.ll

Francois Pichet pichet2000 at gmail.com
Sun Apr 3 16:41:25 PDT 2011


On Sat, Apr 2, 2011 at 6:45 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> Author: efriedma
> Date: Sat Apr  2 17:45:17 2011
> New Revision: 128782
>
> URL: http://llvm.org/viewvc/llvm-project?rev=128782&view=rev
> Log:
> PR9446: RecursivelyDeleteTriviallyDeadInstructions can delete the instruction
> after the given instruction; make sure to handle that case correctly.
> (It's difficult to trigger; the included testcase involves a dead
> block, but I don't think that's a requirement.)
>
> While I'm here, get rid of the unnecessary warning about
> SimplifyInstructionsInBlock, since it should work correctly as far as I know.
>
>
> Added:
>    llvm/trunk/test/Transforms/JumpThreading/2011-04-02-SimplifyDeadBlock.ll
> Modified:
>    llvm/trunk/include/llvm/Transforms/Utils/Local.h
>    llvm/trunk/lib/Transforms/Utils/Local.cpp
>
> Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=128782&r1=128781&r2=128782&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
> +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Sat Apr  2 17:45:17 2011
> @@ -74,10 +74,6 @@
>  ///
>  /// This returns true if it changed the code, note that it can delete
>  /// instructions in other blocks as well in this block.
> -///
> -/// WARNING: Do not use this function on unreachable blocks, as recursive
> -/// simplification is not able to handle corner-case scenarios that can
> -/// arise in them.
>  bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetData *TD = 0);
>
>  //===----------------------------------------------------------------------===//
>
> Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=128782&r1=128781&r2=128782&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sat Apr  2 17:45:17 2011
> @@ -332,8 +332,11 @@
>         BI = BB->begin();
>       continue;
>     }
> -
> +
> +    WeakVH BIHandle(BI);

Here BI can be equal to BB->end()
Hence an end iterator is dereferenced causing the crash in WeakVH
constructor on MSVC




More information about the llvm-commits mailing list