Interprocedural MemorySSA Optimizations
lib/Optimization/IPO/ contains the interprocedural ShadowMem and MemorySSA
optimizations used by the optimization tooling.
Location: lib/Optimization/IPO/
Library target: CanaryOptimizationIPO
Prerequisites
These passes expect IR that has already been prepared with SeaDsa-based
ShadowMem instrumentation. The lotus-opt-ipo frontend inserts the required
setup passes before running any IPO optimization:
RemovePtrToIntAllocWrapInfoDsaLibFuncInfoAllocSiteInfoDsaAnalysisShadowMem
Without that instrumentation, the IPO passes have no shadow.mem.* def-use
chains to analyze.
Main passes
IPDeadStoreElimination(pass nameipdse) removes stores and some global initializers whose ShadowMem def-use chains never reach ashadow.mem.load. It traverses phis plus call/return edges encoded byshadow.mem.arg.*andshadow.mem.in/out.IPRedundantLoadElimination(pass nameip-rle) removes repeated loads inside a basic block when both the pointer operand and the MemorySSA TLVar are identical and no intervening non-ShadowMem memory write occurs.IPStoreSinking(pass nameip-sink) moves a store and its adjacentshadow.mem.storemarker forward within a basic block to just before the earliest observable user when all crossed instructions are side-effect free.IPStoreToLoadForwarding(pass nameip-forward) walks MemorySSA edges across phis and direct-call boundaries to replace a load with a unique reaching stored value.
Configuration
All four passes default to singleton-only regions and expose hidden tuning flags:
IPDeadStoreElimination:-ipdse-only-singleton,-ipdse-max-def-useIPRedundantLoadElimination:-ip-rle-only-singletonIPStoreSinking:-ip-sink-only-singletonIPStoreToLoadForwarding:-ip-forward-only-singleton
These passes are exposed through the interprocedural optimization front-end.
See also Optimization and Inter-Procedural Optimizations.