Index: lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -799,6 +799,15 @@ } } } + + if (auto MD = M.getNamedMetadata("llvm.printf.fmts")) { + for (unsigned I = 0; I < MD->getNumOperands(); ++I) { + auto Node = MD->getOperand(I); + if (Node->getNumOperands() > 0) + emitRuntimeMDStringValue(*OutStreamer, RuntimeMD::KeyPrintfInfo, + cast(Node->getOperand(0))->getString()); + } + } } static std::string getOCLTypeName(Type *Ty, bool Signed) { Index: lib/Target/AMDGPU/AMDGPURuntimeMetadata.h =================================================================== --- lib/Target/AMDGPU/AMDGPURuntimeMetadata.h +++ lib/Target/AMDGPU/AMDGPURuntimeMetadata.h @@ -84,6 +84,7 @@ KeyFlatWorkGroupSizeLimits = 29, // Flat work group size limits KeyMaxWorkGroupSize = 30, // Maximum work group size KeyNoPartialWorkGroups = 31, // No partial work groups + KeyPrintfInfo = 32, // Prinf function call information }; enum Language : uint8_t { Index: test/CodeGen/AMDGPU/runtime-metadata.ll =================================================================== --- test/CodeGen/AMDGPU/runtime-metadata.ll +++ test/CodeGen/AMDGPU/runtime-metadata.ll @@ -16,6 +16,12 @@ ; CHECK-NEXT: .byte 0 ; CHECK-NEXT: .byte 3 ; CHECK-NEXT: .short 200 +; CHECK-NEXT: .byte 32 +; CHECK-NEXT: .long 10 +; CHECK-NEXT: .ascii "1:1:4:%d\\n" +; CHECK-NEXT: .byte 32 +; CHECK-NEXT: .long 10 +; CHECK-NEXT: .ascii "2:1:8:%g\\n" ; CHECK-LABEL:{{^}}test_char: ; CHECK: .section .AMDGPU.runtime_metadata @@ -1018,6 +1024,8 @@ ret void } +!llvm.printf.fmts = !{!100, !101} + !1 = !{i32 0} !2 = !{!"none"} !3 = !{!"int"} @@ -1063,3 +1071,5 @@ !84 = !{!"clk_event_t"} !opencl.ocl.version = !{!90} !90 = !{i32 2, i32 0} +!100 = !{!"1:1:4:%d\5Cn"} +!101 = !{!"2:1:8:%g\5Cn"}