Skip to content

TargetMachine is not thread safe (but it really should be) #27735

@llvmbot

Description

@llvmbot
Bugzilla Link 27361
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @echristo,@joker-eph,@pcc,@rotateright

Extended Description

When doing parallel CodeGen we currently have to create a TargetMachine per-thread because TargetMachine is not thread-safe.
This is a waste, and it would be nice if it can be avoided.
Also, having an immutable TargetMachine is a preliminary step needed if we want at some point parallelize the backend.

Eric pointed out the least amount of work needed:

  • Handle resetTargetOptions first (at least)
  • An optional lock on getSubtarget

The subtarget itself should be fine, and if not, it should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions