Skip to content

Commit

Permalink
Do SORA and DSE in alloc-opt
Browse files Browse the repository at this point in the history
This allow us to handle certain object allocations with object reference fields.
DSE is particularly useful on LLVM 5.0+ where we can take advantage of llvm store to load
forwarding to delete objects that's only used as local buffer.

This is also a prototype for the next gen optimization in type inference and to guide
the new IR format necessary for it.

Fix #16190
  • Loading branch information
yuyichao committed Nov 5, 2017
1 parent 9550c99 commit 327dd1b
Show file tree
Hide file tree
Showing 2 changed files with 755 additions and 74 deletions.
13 changes: 13 additions & 0 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level, bool dump

PM->add(createEarlyCSEPass()); //// ****

#if JL_LLVM_VERSION >= 50000
// Load forwarding above can expose allocations that aren't actually used
// remove those before optimizing loops.
PM->add(createAllocOptPass());
#endif
PM->add(createLoopIdiomPass()); //// ****
PM->add(createLoopRotatePass()); // Rotate loops.
#ifdef USE_POLLY
Expand All @@ -214,6 +219,10 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level, bool dump
PM->add(createSimpleLoopUnrollPass()); // Unroll small loops
//PM->add(createLoopStrengthReducePass()); // (jwb added)

#if JL_LLVM_VERSION >= 50000
// Run our own SROA on heap objects before LLVM's
PM->add(createAllocOptPass());
#endif
// Re-run SROA after loop-unrolling (useful for small loops that operate,
// over the structure of an aggregate)
PM->add(createSROAPass()); // Break up aggregate allocas
Expand All @@ -230,6 +239,10 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level, bool dump
PM->add(createJumpThreadingPass()); // Thread jumps
PM->add(createDeadStoreEliminationPass()); // Delete dead stores

#if JL_LLVM_VERSION >= 50000
// More dead allocation (store) deletion before loop optimization
PM->add(createAllocOptPass());
#endif
// see if all of the constant folding has exposed more loops
// to simplification and deletion
// this helps significantly with cleaning up iteration
Expand Down
Loading

0 comments on commit 327dd1b

Please sign in to comment.