[llvm] [TailDuplicator] Add a limit on the size of predecessors (PR #78582)

Quentin Dian via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 21 02:53:20 PST 2024


DianQK wrote:

> > > the test should be an MIR test right? then it's less prone to various changes affecting the exact codegen of the IR
> > 
> > 
> > Yes, but that would make this test case poorly maintained? I'm not sure, but I can change this.
> 
> What do you mean "poorly maintained"?
> 
> Given that the option works on number of MIR instructions, we should keep the input MIR instruction count consistent.

@aeubanks
I have changed the test case. That was my mistake, I mistakenly thought the mir file would be very large.

> if tail duplication is blowing up code size 4x, that definitely seems like a "we're doing too much tail duplication" issue. but hopefully somebody who actually understands the pass better can comment

@aeubanks
I've updated the issue. I added all the details I could.

> The cause is early-tailduplication transforms normal `switch` to computed-gotos, which means a lot of indirect branches are generated, adding quadratic number of edges inside these cases, that's to say at the end of each case, the control flow is able to jump to other cases directly. As a consequence, passes run after `early-tailduplication` get lag due to a more complex CFG. You may be interested in https://reviews.llvm.org/D110613.

@bzEq
This looks like a very similar patch. But it looks like it's been revert for unknown reasons. What I've found so far is that the main time is `early-tailduplication`.

> If you want to limit the number of tail duplication, I want to see a partial tail duplication base on profile information, similar to MachineBlockPlacement::maybeTailDuplicateBlock.

@weiguozhi
Hmm, CodeGen is not an area I know much about. Could you explain that? What does profile information refer to, the information provided by the PGO?

https://github.com/llvm/llvm-project/pull/78582


More information about the llvm-commits mailing list