[llvm] [AMDGPU] Avoid hitting AMDGPUAsmPrinter related asserts for local functions at O0 (PR #72129)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 05:59:38 PST 2023


JanekvO wrote:

> > Does this fix #64863? We can put it in the commit message if so to close it if this lands.
> 
> This is also part of #71594
> 
> I've debugged this issue a few times and I'm not sure this is sufficient to fix every case. It also produces different behavior from other targets / when CodeGenInSCCOrder is not enabled. Namely, other targets will codegen and emit the code for the dead functions and here you're not emitting anything.

I thought it'd be best to be consistent in the codegen pass pipeline with the CallGraphSCC ordering. If the CodeGenInSCCOrder is enabled for other targets (i.e., using --enable-ipra) it also emit nothing. I was hoping for there to be a target independent solution but couldn't find anything beyond trying to convince CallGraphSCC to run all SCCs.
> 
> The problem isn't uncalled functions per-se, but functions which do not appear in the CallGraphSCC order. Functions which are only indirectly called still should report sensible register usage, but will also not necessarily codegen in the correct order. 

Ah, I wasn't aware of any issues with indirect called functions. I thought the order of non-local functions was still considered by CallGraphSCC, including indirect calls.
> I had a patch which I believe did fix all cases by inserting a createBarrierNoopPass, such that all codegen was forced to happen prior to the AsmPrinter but this is a heavy hammer. Ideally the AsmPrinter wouldn't have any ordering dependencies.

I'm not sure at what point the BarrierNoopPass would be inserted but if put too early it'd undo the CallGraphSCC ordering and if put too late the AsmPrinter will assert on trying to emit code for a MachineFunction without basic blocks, right?
> 
> I think the long term solution is to move the handling of the resource computation into MC. The assembler/linker should be able to resolve some kind of custom expression built in terms of referenced symbols

AFAICT, that would avoid the asserts from being hit but wouldn't stop the codegen passes ignoring any functions not in the CallGraphSCC (i.e., emitting nothing for said functions).


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


More information about the llvm-commits mailing list