Skip to content

Prevent "Target-incompatible DataLayout" LLVM asserts. #33446

Description

@eddyb

Example of such an assertion:
Assertion 'TM.isCompatibleDataLayout(getDataLayout()) && "Can't create a MachineFunction using a Module with a " "Target-incompatible DataLayout attached\n"' failed.

It appears that since LLVM 3.7, DataLayout is checked for target compatibility, and as joker-eph on LLVM's IRC channel on OFTC explains:

technically a Target can implement a "compatibility check" if it is willing to relax the constrain that the DL matches, but we haven't implemented anything like that that I know of. So the backend check if the Module data layout is the same as what the target wants.

The relevant method is bool TargetMachine::isCompatibleDataLayout(const DataLayout &Candidate).

joker-eph suggests warning and overriding an incompatible data layout with the target default.
However, I don't think we can do anything but error because we would've already used the (incompatible) data layout string for determining type layouts.

We can at least provide the target default data layout string for the user in that situation.
cc @alexcrichton

Activity

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

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions