Skip to content

Slow compilation when inlining code without debug infos #3130

Closed

Description

@mkroll-nv

For some 4 MB generated HLSL code (which I'm not allowed to share :( ), involving quite a deep call graph with lots of calls, the compilation with the DirectXShaderCompiler (commit e3a8344) is very slow.
Using the profiler of Visual Studio on a RelWithDebInfo build of dxc with "-T lib_6_5 " as command line, I got this result (aborting after two minutes of compilation):

image

When a call is inlined in llvm::InlineFunction(), the inliner tries to update the line number information using fixupLineNumbers().
If the call itself doesn't have a debug location, it looks up the debug information for the function containing the inlined call with getDISubprogram().

image

if (DISubprogram *Subprogram = getDISubprogram(Fn)) {

This function iterates over all instructions of the function until it finds debug information or the end of the function.

image

When we compile without debug information, have a lot of functions to inline and produce more and more code by all the inlining, this takes quite a significant amount of time, without adding anything to the result, as there is no debug info to be found.
Also the assumption in the comment in fixupLineNumbers() is wrong, that the inlined calls are from global variable initialization. These are normal functions calls.
Calling getDISubprogram() was introduced with 3811872.

Activity

  1. added a commit that references this issue on Feb 22, 2021
    82bacaf
  2. added a commit that references this issue on Feb 23, 2021
    e2b32bc
  3. pow2clk commented on Feb 23, 2021

    @pow2clk
    Collaborator

    Hi mkroll-nv!

    The submitted fix is just a bit speculative, so I'd appreciate confirmation that it resolves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions