Skip to content

[SystemZ] Large compile time regression in SystemZTTIImpl::adjustInliningThreshold() #134714

Open
@alexrp

Description

@alexrp

#106058 appears to have caused a large compile time regression in LLVM 20. zig-bootstrap used to be able to compile and link the zig binary for s390x-linux-(gnu,musl) in a matter of minutes when we were on LLVM 19. Now on LLVM 20, I decided to cancel the build after it had been running for about an hour.

Some investigation shows that a lot of time is being spent in SystemZTTIImpl::adjustInliningThreshold(), in particular in this section:

for (const GlobalVariable &Global : M->globals())
for (const User *U : Global.users())
if (const Instruction *User = dyn_cast<Instruction>(U)) {
if (User->getParent()->getParent() == Callee)
CalleeGlobals.insert(&Global);
if (User->getParent()->getParent() == Caller)
CallerGlobals.insert(&Global);
}

Some thoughts:

  • A module can have lots of globals.
    • This doesn't appear to be the problem here, however.
  • A global can have lots of users (think common deduplicated/merged constant values).
    • This seems to be the case here, though I couldn't determine exactly how many users we're talking about because I was using a RelWithDebInfo build of LLVM where p Global.users() was optimized out.
      • Building a Debug compiler as I file this to hopefully find out...
  • std::set seems less than ideal compared to std::unordered_set here.
    • I tried changing this to std::unordered_set but it didn't seem to have too much of an impact. Still seems desirable to do, though.

In general, all of this seems like a lot of work to be doing on ~every inlining decision.

cc @JonPsson1 @uweigand

Metadata

Metadata

Assignees

Type

Projects

Status

Needs Fix

Relationships

None yet

Development

No branches or pull requests

Issue actions