Skip to content

llvmcall attributes are lost #437

@maleadt

Description

@maleadt

Take this function:

@inline function barrier(flag=0)
    Base.llvmcall(("""
        declare void @air.wg.barrier(i32, i32) #1

        define void @entry(i32 %flag) #0 {
            call void @air.wg.barrier(i32 %flag, i32 1)
            ret void
        }

        attributes #0 = { alwaysinline }
        attributes #1 = { convergent }""", "entry"),
    Nothing, Tuple{Cuint}, convert(Cuint, flag))
end

Note how air.wg.barrier has been marked with the convergent attribute. Julia's code_llvm keeps that around:

julia> f() = barrier()
f (generic function with 1 method)

julia> code_llvm(f, Tuple{}; raw=true, dump_module=true)

; Function Attrs: convergent
declare void @air.wg.barrier(i32, i32) #2

GPUCompiler doesn't:

julia> Metal.code_llvm(f, Tuple{}; raw=true, dump_module=true)

declare void @air.wg.barrier(i32, i32) local_unnamed_addr

That's bad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions