[llvm] r257279 - [JumpThreading] Don't forget to report that the IR changed
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 10 21:21:29 PST 2016
any way to test this?
On Sat, Jan 9, 2016 at 11:13 PM, David Majnemer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: majnemer
> Date: Sun Jan 10 01:13:04 2016
> New Revision: 257279
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257279&view=rev
> Log:
> [JumpThreading] Don't forget to report that the IR changed
>
> JumpThreading's runOnFunction is supposed to return true if it made any
> changes. JumpThreading has a call to removeUnreachableBlocks which may
> result in changes to the IR but runOnFunction didn't appropriate account
> for this possibility, leading to badness.
>
> While we are here, make sure to call LazyValueInfo::eraseBlock in
> removeUnreachableBlocks; JumpThreading preserves LVI.
>
> This fixes PR26096.
>
> Modified:
> llvm/trunk/include/llvm/Transforms/Utils/Local.h
> llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> 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=257279&r1=257278&r2=257279&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
> +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Sun Jan 10 01:13:04
> 2016
> @@ -42,6 +42,7 @@ class TargetLibraryInfo;
> class TargetTransformInfo;
> class DIBuilder;
> class DominatorTree;
> +class LazyValueInfo;
>
> template<typename T> class SmallVectorImpl;
>
> @@ -303,7 +304,7 @@ void removeUnwindEdge(BasicBlock *BB);
> /// \brief Remove all blocks that can not be reached from the function's
> entry.
> ///
> /// Returns true if any basic block was removed.
> -bool removeUnreachableBlocks(Function &F);
> +bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI = nullptr);
>
> /// \brief Combine the metadata of two instructions so that K can replace
> J
> ///
>
> Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=257279&r1=257278&r2=257279&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Jan 10 01:13:04
> 2016
> @@ -211,11 +211,12 @@ bool JumpThreading::runOnFunction(Functi
> // we will loop forever. We take care of this issue by not jump
> threading for
> // back edges. This works for normal cases but not for unreachable
> blocks as
> // they may have cycle with no back edge.
> - removeUnreachableBlocks(F);
> + bool EverChanged = false;
> + EverChanged |= removeUnreachableBlocks(F, LVI);
>
> FindLoopHeaders(F);
>
> - bool Changed, EverChanged = false;
> + bool Changed;
> do {
> Changed = false;
> for (Function::iterator I = F.begin(), E = F.end(); I != E;) {
>
> Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=257279&r1=257278&r2=257279&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Jan 10 01:13:04 2016
> @@ -23,6 +23,7 @@
> #include "llvm/Analysis/EHPersonalities.h"
> #include "llvm/Analysis/InstructionSimplify.h"
> #include "llvm/Analysis/MemoryBuiltins.h"
> +#include "llvm/Analysis/LazyValueInfo.h"
> #include "llvm/Analysis/ValueTracking.h"
> #include "llvm/IR/CFG.h"
> #include "llvm/IR/Constants.h"
> @@ -1407,7 +1408,7 @@ void llvm::removeUnwindEdge(BasicBlock *
> /// removeUnreachableBlocksFromFn - Remove blocks that are not reachable,
> even
> /// if they are in a dead cycle. Return true if a change was made, false
> /// otherwise.
> -bool llvm::removeUnreachableBlocks(Function &F) {
> +bool llvm::removeUnreachableBlocks(Function &F, LazyValueInfo *LVI) {
> SmallPtrSet<BasicBlock*, 128> Reachable;
> bool Changed = markAliveBlocks(F, Reachable);
>
> @@ -1428,6 +1429,8 @@ bool llvm::removeUnreachableBlocks(Funct
> ++SI)
> if (Reachable.count(*SI))
> (*SI)->removePredecessor(&*BB);
> + if (LVI)
> + LVI->eraseBlock(&*BB);
> BB->dropAllReferences();
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160110/88a950e7/attachment.html>
More information about the llvm-commits
mailing list