1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
; RUN: llc -o - %s -march=nvptx -mcpu=sm_20 | FileCheck %s
; Check that we do global variable demotion when the symbols don't need to be
; shared across modules or functions.
; Variable visible globally can't be demoted.
; CHECK: .visible .shared .align 4 .u64 external_global
@external_global = addrspace(3) global i64 undef, align 4
; Not externally visible global used in only one function => demote.
; It should live in @define_internal_global.
@internal_global = internal addrspace(3) global i64 undef, align 4
; Not externally visible global used in several functions => keep.
; CHECK: .shared .align 4 .u64 internal_global_used_in_different_fcts
@internal_global_used_in_different_fcts = internal addrspace(3) global i64 undef, align 4
; Not externally visible global used in only one function => demote.
; It should live in @define_private_global.
@private_global = private addrspace(3) global i64 undef, align 4
; Not externally visible global used in only one function
; (but with several uses) => demote.
; It should live in @define_private_global_more_than_one_use.
@private_global_used_more_than_once_in_same_fct = private addrspace(3) global i64 undef, align 4
; CHECK-LABEL: define_external_global(
define void @define_external_global(i64 %val) {
store i64 %val, ptr addrspace(3) @external_global
ret void
}
; CHECK-LABEL: define_internal_global(
; Demoted `internal_global` should live here.
; CHECK: .shared .align 4 .u64 internal_global
define void @define_internal_global(i64 %val) {
store i64 %val, ptr addrspace(3) @internal_global
ret void
}
; CHECK-LABEL: define_internal_global_with_different_fct1(
; CHECK-NOT: .shared .align 4 .u64 internal_global_used_in_different_fcts
define void @define_internal_global_with_different_fct1(i64 %val) {
store i64 %val, ptr addrspace(3) @internal_global_used_in_different_fcts
ret void
}
; CHECK-LABEL: define_internal_global_with_different_fct2(
; CHECK-NOT: .shared .align 4 .u64 internal_global_used_in_different_fcts
define void @define_internal_global_with_different_fct2(i64 %val) {
store i64 %val, ptr addrspace(3) @internal_global_used_in_different_fcts
ret void
}
; CHECK-LABEL: define_private_global(
; Demoted `private_global` should live here.
; CHECK: .shared .align 4 .u64 private_global
define void @define_private_global(i64 %val) {
store i64 %val, ptr addrspace(3) @private_global
ret void
}
; CHECK-LABEL: define_private_global_more_than_one_use(
; Demoted `private_global_used_more_than_once_in_same_fct` should live here.
; CHECK: .shared .align 4 .u64 private_global_used_more_than_once_in_same_fct
;
; Also check that the if-then is still here, otherwise we may not be testing
; the "more-than-one-use" part.
; CHECK: st.shared.u64 [private_global_used_more_than_once_in_same_fct],
; CHECK: mov.u64 %[[VAR:.*]], 25
; CHECK: st.shared.u64 [private_global_used_more_than_once_in_same_fct], %[[VAR]]
define void @define_private_global_more_than_one_use(i64 %val, i1 %cond) {
store i64 %val, ptr addrspace(3) @private_global_used_more_than_once_in_same_fct
br i1 %cond, label %then, label %end
then:
store i64 25, ptr addrspace(3) @private_global_used_more_than_once_in_same_fct
br label %end
end:
ret void
}
|