Skip to content

Converting the cir.triple attribute of the llvm.triple attribute when lowering throughmlir #1619

@felixdaas

Description

@felixdaas

When compiling a simple C File with the indirect lowering through mlir, the cir.triple attribute isn't converted to an equivilant llvm.triple. Because of this the compilation fails with

error: unable to create target: 'No available targets are compatible with triple ""'

Since there is no builtin attribute that could be used to represent the target triple in the core dialects, i would suggest including this conversion in the ConvertMLIRToLLVMPass. This way no llvm mlir attribute is used in the core dialect mlir representation, but the target triple is correctly propageted when compiling via llvm.

Here's a minimal example that triggers the issue:

test.c

int main(int argc, char *argv[]) {
    // Variables
    int number = 15;

    number = number + 10;

    return 0;
}

when trying to compile this file with the indirect lowering this leads to the following error:

clang -fclangir -fno-clangir-direct-lowering test.c 
error: unable to create target: 'No available targets are compatible with triple ""'
1 error generated.

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