Subzero: Find rematerializable variables transitively. There are situations where a variable is assigned as the result of a rematerializable alloca instruction, and then another variable is assigned as essentially a known-offset interior pointer into the alloca space. In this case, the secondary variable is also rematerializable. We add a pass, after alloca analysis, to find these derived variables and mark them transitively as rematerializable. Because we lack use-def chains (or in fact any map to variable use locations), we need to iterate over the CFG until convergence. Fortunately, this is pretty cheap, and not even done unless the alloca analysis seeds it with an initial set of rematerializable variables. This analysis is only really needed for arithmetic instructions, but we also need to apply it to assignments and pointer-type bitcasts that are added when the IceConverter directly parses a .ll file rather than a .pexe file. BUG= none R=jpp@chromium.org, sehr@chromium.org Review URL: https://codereview.chromium.org/1441793002 .
diff --git a/src/IceCfg.h b/src/IceCfg.h index b39673b..6c64e25 100644 --- a/src/IceCfg.h +++ b/src/IceCfg.h
@@ -191,14 +191,6 @@ void reorderNodes(); void shuffleNodes(); - enum AllocaBaseVariableType { - BVT_StackPointer, - BVT_FramePointer, - BVT_UserPointer - }; - void sortAndCombineAllocas(CfgVector<Inst *> &Allocas, - uint32_t CombinedAlignment, InstList &Insts, - AllocaBaseVariableType BaseVariableType); /// Scan allocas to determine whether we need to use a frame pointer. /// If SortAndCombine == true, merge all the fixed-size allocas in the /// entry block and emit stack or frame pointer-relative addressing. @@ -267,6 +259,16 @@ /// Iterate through the registered jump tables and emit them. void emitJumpTables(); + enum AllocaBaseVariableType { + BVT_StackPointer, + BVT_FramePointer, + BVT_UserPointer + }; + void sortAndCombineAllocas(CfgVector<Inst *> &Allocas, + uint32_t CombinedAlignment, InstList &Insts, + AllocaBaseVariableType BaseVariableType); + void findRematerializable(); + GlobalContext *Ctx; uint32_t SequenceNumber; /// output order for emission uint32_t ConstantBlindingCookie = 0; /// cookie for constant blinding