Skip to content

Commit

Permalink
Add renaming global test
Browse files Browse the repository at this point in the history
  • Loading branch information
pchintalapudi committed Jan 3, 2023
1 parent 6faab55 commit 79bccd8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/llvmcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,34 @@ module CcallableRetTypeTest
@test do_the_call() === 42.0
end

# Issue #48093 - test that non-external globals are not deduplicated
@inline shmem() = Base.llvmcall(("""
@shmem = internal global [1 x i8] zeroinitializer, align 32
define i8* @entry() #0 {
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @shmem, i64 0, i64 0)
}
attributes #0 = { alwaysinline }""", "entry"),
Core.LLVMPtr{Int8,0}, Tuple{})

function kernel2()
ptr1 = reinterpret(Ptr{Int8}, shmem())
arr1 = unsafe_wrap(Array, ptr1, 1)
ptr2 = reinterpret(Ptr{Int8}, shmem())
arr2 = unsafe_wrap(Array, ptr2, 1)
@inbounds begin
arr1[] = 1
arr2[]
end
end

get_module_ir(io, f, types) = code_llvm(io, f, types, dump_module=true, raw=true)

ir = sprint(get_module_ir, kernel2, Tuple{})

@test length(collect(eachmatch(r"internal global", ir))) == 2

# If this test breaks, you've probably broken Cxx.jl - please check
module LLVMCallFunctionTest
using Base: llvmcall
Expand Down

0 comments on commit 79bccd8

Please sign in to comment.