Fatal error: error in backend: Broken module found, compilation aborted! while processing profiled LLVM IR with Oz optimization
Hi, I'm encountering a backend compilation error while using the LLVM inliner in release mode on a .ll file that contains call graph profile metadata.
Setup
LLVM/Clang Version: clang version 17.0.0 Commit: f4dbf5babe7a0089322ed64d1623fb31f7d51898 Target: x86_64-unknown-linux-gnu Optimization level: -Oz
Input: LLVM IR file containing the following metadata
!33 = !{i32 5, !"CG Profile", !34}
Error message
module flag identifiers must be unique (or of 'require' type) !"CG Profile" fatal error: error in backend: Broken module found, compilation aborted!
Issue
When trying to process the IR with the inliner, I get a fatal backend error stating that the module flag identifiers must be unique. The error seems to be related to the !"CG Profile" flag.
Please find the attached ll file for your reference.
Could you please try 20 or main branch? https://godbolt.org should be helpful.
Could you please try 20 or
mainbranch? https://godbolt.org should be helpful.
Actually, I want to process the profiled .ll files with clang version 17.0.0. Is there any fix for this version?
Only most recent release in maintained.
Do you mean that this issue persists with clang version 17.0.0?
If problem was fixed in later version you could try to find fix and backport it to 17.x branch yourself.
I have observed that the current LLVM Inliner does not process the CG Profile metadata correctly. When the CG metadata entry !33 = !{i32 5, !"CG Profile", !34} is included in !llvm.module.flags, the LLVM Inliner fails to process the IR. Removing this entry from !llvm.module.flags = !{!0, !1, !2, !3, !4, !33} allows it to proceed as expected.
This suggests that the Inliner may require modifications to support CG Profile metadata. I would appreciate any suggestions or directions you may have on addressing this.