[PATCH] D59613: [AMDGPU] Do not generate spurious PAL metadata

Tim Renouf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 14:10:42 PDT 2019


tpr created this revision.
Herald added subscribers: llvm-commits, t-tye, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.

My previous fix rL356591 <https://reviews.llvm.org/rL356591> "[AMDGPU] Added MsgPack format PAL metadata"
accidentally caused a spurious PAL metadata .note record to be emitted
for any AMDGPU output. That caused failures in the lld test
amdgpu-relocs.s. Fixed.

Change-Id: Ie04a2aaae890dcd490f22c89edf9913a77ce070e


Repository:
  rL LLVM

https://reviews.llvm.org/D59613

Files:
  lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
  lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
  test/MC/AMDGPU/spurious-pal-metadata.s


Index: test/MC/AMDGPU/spurious-pal-metadata.s
===================================================================
--- /dev/null
+++ test/MC/AMDGPU/spurious-pal-metadata.s
@@ -0,0 +1,8 @@
+# RUN: llvm-mc -triple=amdgcn--amdhsa -mcpu=fiji %s | FileCheck %s --check-prefix=ASM
+# RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o
+# RUN: llvm-objdump -s %t.o | FileCheck %s --check-prefix=OBJDUMP
+
+# Check that we don't get spurious PAL metadata. 
+
+# ASM-NOT: pal_metadata
+# OBJDUMP-NOT: section .note
Index: lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
===================================================================
--- lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
+++ lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
@@ -92,8 +92,8 @@
 
   // Get .note record type of metadata blob to be emitted:
   // ELF::NT_AMD_AMDGPU_PAL_METADATA (legacy key=val format), or
-  // ELF::NT_AMD_AMDGPU_PAL_METADATA_MSGPACK or ELF::NT_AMDGPU_METADATA
-  // (MsgPack format).
+  // ELF::NT_AMDGPU_METADATA (MsgPack format), or
+  // 0 (no PAL metadata).
   unsigned getType() const;
 
   // Emit the accumulated PAL metadata as a binary blob.
Index: lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
===================================================================
--- lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
+++ lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
@@ -518,6 +518,8 @@
 // Convert the accumulated PAL metadata into an asm directive.
 void AMDGPUPALMetadata::toString(std::string &String) {
   String.clear();
+  if (!BlobType)
+    return;
   raw_string_ostream Stream(String);
   if (isLegacy()) {
     if (MsgPackDoc.getRoot().getKind() == msgpack::Type::Nil)
@@ -564,11 +566,12 @@
 }
 
 // Convert the accumulated PAL metadata into a binary blob for writing as
-// a .note record of the specified AMD type.
+// a .note record of the specified AMD type. Returns an empty blob if
+// there is no PAL metadata,
 void AMDGPUPALMetadata::toBlob(unsigned Type, std::string &Blob) {
   if (Type == ELF::NT_AMD_AMDGPU_PAL_METADATA)
     toLegacyBlob(Blob);
-  else
+  else if (Type)
     toMsgPackBlob(Blob);
 }
 
@@ -678,9 +681,10 @@
 
 // Get .note record type of metadata blob to be emitted:
 // ELF::NT_AMD_AMDGPU_PAL_METADATA (legacy key=val format), or
-// ELF::NT_AMDGPU_METADATA (MsgPack format).
+// ELF::NT_AMDGPU_METADATA (MsgPack format), or
+// 0 (no PAL metadata).
 unsigned AMDGPUPALMetadata::getType() const {
-  return BlobType ? BlobType : unsigned(ELF::NT_AMDGPU_METADATA);
+  return BlobType;
 }
 
 // Return whether the blob type is legacy PAL metadata.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59613.191578.patch
Type: text/x-patch
Size: 2593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190320/ddbe80e7/attachment.bin>


More information about the llvm-commits mailing list