Skip to content

Commit 79bccd8

Browse files
committed
Add renaming global test
1 parent 6faab55 commit 79bccd8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/llvmcall.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ module CcallableRetTypeTest
205205
@test do_the_call() === 42.0
206206
end
207207

208+
# Issue #48093 - test that non-external globals are not deduplicated
209+
@inline shmem() = Base.llvmcall(("""
210+
@shmem = internal global [1 x i8] zeroinitializer, align 32
211+
212+
define i8* @entry() #0 {
213+
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @shmem, i64 0, i64 0)
214+
}
215+
216+
attributes #0 = { alwaysinline }""", "entry"),
217+
Core.LLVMPtr{Int8,0}, Tuple{})
218+
219+
function kernel2()
220+
ptr1 = reinterpret(Ptr{Int8}, shmem())
221+
arr1 = unsafe_wrap(Array, ptr1, 1)
222+
ptr2 = reinterpret(Ptr{Int8}, shmem())
223+
arr2 = unsafe_wrap(Array, ptr2, 1)
224+
@inbounds begin
225+
arr1[] = 1
226+
arr2[]
227+
end
228+
end
229+
230+
get_module_ir(io, f, types) = code_llvm(io, f, types, dump_module=true, raw=true)
231+
232+
ir = sprint(get_module_ir, kernel2, Tuple{})
233+
234+
@test length(collect(eachmatch(r"internal global", ir))) == 2
235+
208236
# If this test breaks, you've probably broken Cxx.jl - please check
209237
module LLVMCallFunctionTest
210238
using Base: llvmcall

0 commit comments

Comments
 (0)