Skip to content

[Clang] CS-IR PGO doesn't generate profiles with LTO enabled  #112103

@gitoss

Description

@gitoss

I'm trying to use IR+CS-IR PGO to optimize the SVT-AV1-PSY encoder psy-ex/svt-av1-psy#69 (reply in thread)

A binary compiled with -fcs-profile-generate -fprofile-use= silently fails to generate any profiles if (thin or full) LTO is enabled. This happens on LLVM 17 (Visual Stdío built-in) and LLVM 19 (last official binary available).

This seems to be a problem with other source code, too https://www.reddit.com/r/LLVM/comments/182psjg/comment/lrdktnd/?context=3

This could be a bug or "works as designed" because LTO defers performing optimization until link time https://llvm.org/docs/LinkTimeOptimization.html - but context sensitive PGO performs a post-inline late instrumentation https://clang.llvm.org/docs/UsersManual.html

If whis is "wad" please a) add the information about incompatibility with -fcs-profile-generate and -flto to the documentation, b) add a clang error/warning if this combination is used or c) warn and auto-disable -flto if -fcs-profile-generate is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LTOLink time optimization (regular/full LTO or ThinLTO)PGOProfile Guided Optimizations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions