<div dir="ltr">I spent some time looking at this.<div><br></div><div>Hal, I think we need to revert all of this. =[</div><div><br></div><div>The operand bundle thing solves a very real issue in InstCombine and ValueTracking but it makes the inline cost computation superlinear. I'm actually amazed we didn't see this sooner.</div><div><br></div><div>A fundamental requirement of the current inliner is that inline cast has a fixed constant bound on the cost of computing it. With this change, the cost can be linear because we will walk every single instruction in the callee to determine that it isn't an assume. The test cases here have *no* assume instructions in them. So this seems really bad in terms of regressions: we made code *without* assumes slower to make code *with* assumes faster. =/ But it is also superlinear. If you imagine a module with two functions, one of which calls the other N times and the other calls the first N times, I'm pretty sure we'll examine all N instructions of one function for each of the N call sites in the other.</div><div><br></div><div>The test cases here aren't terribly pathological and they still seem to trigger this behavior. =/</div><div><br></div><div>I don't see any particularly easy ways around this either. This is in fact what a caching approach to function analyses in the new PM is designed to solve -- it allows us to not do linear work here by caching results. Eventually, the 'collectEphemeralValues' call will actually just lookup an ephemeral values analysis and use its cached results.</div><div><br></div><div>Until then, I actually think the (somewhat hacky) caching scheme the AssumptionCache was using is the right approach. I would use the AssumptionCache for CodeMetrics and building the ephemeral value set, and then use the operands for everything else. Then, in the new PM, we can replace the AssumptionCache with a more elegant cached set of ephemeral values.</div><div><br></div><div>I've told Daniel to go ahead and revert this to get non-assume-heavy things back to linear compile time. If my suggestion doesn't make sense, poke me, happy to chat about alternatives here.</div><div><br></div><div>-Chandler</div></div>