diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1290,6 +1290,8 @@ O << "."; emitPTXAddressSpace(GVar->getType()->getAddressSpace(), O); + if (isManaged(*GVar)) + O << " .attribute(.managed)"; if (MaybeAlign A = GVar->getAlign()) O << " .align " << A->value(); else diff --git a/llvm/test/CodeGen/NVPTX/managed.ll b/llvm/test/CodeGen/NVPTX/managed.ll --- a/llvm/test/CodeGen/NVPTX/managed.ll +++ b/llvm/test/CodeGen/NVPTX/managed.ll @@ -6,6 +6,11 @@ ; CHECK: .visible .global .attribute(.managed) .align 4 .u32 managed_g; @managed_g = addrspace(1) global i32 zeroinitializer +; CHECK: .extern .global .align 4 .u32 decl_g; +@decl_g = external addrspace(1) global i32, align 4 +; CHECK: .extern .global .attribute(.managed) .align 8 .b32 managed_decl_g; +@managed_decl_g = external addrspace(1) global i32*, align 8 -!nvvm.annotations = !{!0} +!nvvm.annotations = !{!0, !1} !0 = !{i32 addrspace(1)* @managed_g, !"managed", i32 1} +!1 = !{i32* addrspace(1)* @managed_decl_g, !"managed", i32 1}