1; RUN: opt -S -mtriple=amdgcn-- -amdgpu-lower-module-lds < %s | FileCheck %s 2; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s | FileCheck %s 3 4; Check new struct is added to compiler.used and that the replaced variable is removed 5 6; CHECK: %llvm.amdgcn.module.lds.t = type { float } 7; CHECK: @ignored = addrspace(1) global i64 0 8; CHECK: @llvm.amdgcn.module.lds = internal addrspace(3) global %llvm.amdgcn.module.lds.t undef, align 8 9 10; CHECK-NOT: @tolower 11 12@tolower = addrspace(3) global float undef, align 8 13 14; A variable that is unchanged by pass 15@ignored = addrspace(1) global i64 0 16 17 18; @ignored still in list, @tolower removed, llvm.amdgcn.module.lds appended 19; Start with one value to replace and one to ignore in the .use list 20 21; @ignored still in list, @tolower removed 22; CHECK: @llvm.used = appending global [1 x i8*] [i8* addrspacecast (i8 addrspace(1)* bitcast (i64 addrspace(1)* @ignored to i8 addrspace(1)*) to i8*)], section "llvm.metadata" 23 24@llvm.used = appending global [2 x i8*] [i8* addrspacecast (i8 addrspace(3)* bitcast (float addrspace(3)* @tolower to i8 addrspace(3)*) to i8*), i8* addrspacecast (i8 addrspace(1)* bitcast (i64 addrspace(1)* @ignored to i8 addrspace(1)*) to i8*)], section "llvm.metadata" 25 26; @ignored still in list, @tolower removed, llvm.amdgcn.module.lds appended 27; CHECK: @llvm.compiler.used = appending global [2 x i8*] [i8* addrspacecast (i8 addrspace(1)* bitcast (i64 addrspace(1)* @ignored to i8 addrspace(1)*) to i8*), i8* addrspacecast (i8 addrspace(3)* bitcast (%llvm.amdgcn.module.lds.t addrspace(3)* @llvm.amdgcn.module.lds to i8 addrspace(3)*) to i8*)], section "llvm.metadata" 28 29@llvm.compiler.used = appending global [2 x i8*] [i8* addrspacecast (i8 addrspace(3)* bitcast (float addrspace(3)* @tolower to i8 addrspace(3)*) to i8*), i8* addrspacecast (i8 addrspace(1)* bitcast (i64 addrspace(1)* @ignored to i8 addrspace(1)*) to i8*)], section "llvm.metadata" 30 31; CHECK-LABEL: @func() 32; CHECK: %dec = atomicrmw fsub float addrspace(3)* getelementptr inbounds (%llvm.amdgcn.module.lds.t, %llvm.amdgcn.module.lds.t addrspace(3)* @llvm.amdgcn.module.lds, i32 0, i32 0), float 1.000000e+00 monotonic, align 8 33define void @func() { 34 %dec = atomicrmw fsub float addrspace(3)* @tolower, float 1.0 monotonic 35 %unused0 = atomicrmw add i64 addrspace(1)* @ignored, i64 1 monotonic 36 ret void 37} 38