1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 21:42:54 +02:00
llvm-mirror/lib/Transforms/Utils
Duncan P. N. Exon Smith 457d9e7336 ValueMapper/Enumerator: Clean up code in post-order traversals, NFC
Re-layer the functions in the new (i.e., newly correct) post-order
traversals in ValueEnumerator (r266947) and ValueMapper (r266949).
Instead of adding a node to the worklist in a helper function and
returning a flag to say what happened, return the node itself.  This
makes the code way cleaner: the worklist is local to the main function,
there is no flag for an early loop exit (since we can cleanly bury the
loop), and it's perfectly clear when pointers into the worklist might be
invalidated.

I'm fixing both algorithms in the same commit to avoid repeating the
commit message; if you take the time to understand one the other should
be easy.  The diff itself isn't entirely obvious since the traversals
have some noise (i.e., things to do), but here's the high-level change:

    auto helper = [&WL](T *Op) {     auto helper = [](T **&I, T **E) {
                                 =>    while (I != E) {
      if (shouldVisit(Op)) {             T *Op = *I++;
        WL.push(Op, Op->begin());        if (shouldVisit(Op)) {
        return true;                       return Op;
      }                                }
      return false;                    return nullptr;
    };                               };
                                 =>
    WL.push(S, S->begin());          WL.push(S, S->begin());
    while (!empty()) {               while (!empty()) {
      auto *N = WL.top().N;            auto *N = WL.top().N;
      auto *&I = WL.top().I;           auto *&I = WL.top().I;
      bool DidChange = false;
      while (I != N->end())
        if (helper(*I++)) {      =>    if (T *Op = helper(I, N->end()) {
          DidChange = true;              WL.push(Op, Op->begin());
          break;                         continue;
        }                              }
      if (DidChange)
        continue;

      POT.push(WL.pop());        =>    POT.push(WL.pop());
    }                                }

Thanks to Mehdi for helping me find a better way to layer this.

llvm-svn: 267099
2016-04-22 02:33:06 +00:00
..
AddDiscriminators.cpp Fix null pointer access for discriminator assignment. 2016-04-14 19:46:38 +00:00
ASanStackFrameLayout.cpp
BasicBlockUtils.cpp [LV] Preserve LoopInfo when store predication is used 2016-03-15 18:06:20 +00:00
BreakCriticalEdges.cpp
BuildLibCalls.cpp
BypassSlowDivision.cpp
CloneFunction.cpp Transforms: Try harder to fix bootstrap after r266565 2016-04-17 20:11:09 +00:00
CloneModule.cpp Preserve extern_weak linkage in CloneModule. 2016-03-31 20:21:31 +00:00
CMakeLists.txt Add a pass to name anonymous/nameless function 2016-04-12 21:35:28 +00:00
CmpInstAnalysis.cpp
CodeExtractor.cpp
CtorUtils.cpp
DemoteRegToStack.cpp
Evaluator.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
FlattenCFG.cpp
FunctionImportUtils.cpp [ThinLTO] Prevent importing of "llvm.used" values 2016-04-20 14:39:45 +00:00
GlobalStatus.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
InlineFunction.cpp Maintain calling convention when inling calls to llvm.deoptimize 2016-04-09 00:22:59 +00:00
InstructionNamer.cpp
IntegerDivision.cpp TransformUtils: Avoid getNodePtrUnchecked() in integer division, NFC 2016-02-21 20:14:29 +00:00
LCSSA.cpp [AA] Preserve the AA results wrapper pass as well as BasicAA in a few 2016-02-19 03:12:14 +00:00
LLVMBuild.txt
Local.cpp [SimplifyCFG] Fold llvm.guard(false) to unreachable 2016-04-21 05:09:12 +00:00
LoopSimplify.cpp
LoopUnroll.cpp Follow-up for r265605: don't mutate vector we're iterating. 2016-04-07 00:09:42 +00:00
LoopUnrollRuntime.cpp Transforms: Fix bootstrap after r266565 2016-04-17 19:26:49 +00:00
LoopUtils.cpp [LoopUtils] Fix typo in comment 2016-04-21 17:33:22 +00:00
LoopVersioning.cpp [LoopVersioning] Relax an assert for LCSSA PHIs 2016-03-22 18:38:15 +00:00
LowerInvoke.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
LowerSwitch.cpp
Mem2Reg.cpp Initial implementation of optimization bisect support. 2016-04-21 17:58:54 +00:00
MemorySSA.cpp Correct IDF calculator for ReverseIDF 2016-04-19 06:13:28 +00:00
MetaRenamer.cpp
ModuleUtils.cpp [ThinLTO] Prevent importing of "llvm.used" values 2016-04-20 14:39:45 +00:00
NameAnonFunctions.cpp Fix mismatch on returned type between header and implementation for createNameAnonFunctionPass() 2016-04-12 23:25:11 +00:00
PromoteMemoryToRegister.cpp Correct IDF calculator for ReverseIDF 2016-04-19 06:13:28 +00:00
SanitizerStats.cpp
SimplifyCFG.cpp [ValueTracking] Make isImpliedCondition return an Optional<bool>. NFC. 2016-04-20 19:15:26 +00:00
SimplifyIndVar.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
SimplifyInstructions.cpp
SimplifyLibCalls.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
SplitModule.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
SSAUpdater.cpp
SymbolRewriter.cpp
UnifyFunctionExitNodes.cpp
Utils.cpp Add a pass to name anonymous/nameless function 2016-04-12 21:35:28 +00:00
ValueMapper.cpp ValueMapper/Enumerator: Clean up code in post-order traversals, NFC 2016-04-22 02:33:06 +00:00