]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Do not generate spurious PAL metadata
authorTim Renouf <tpr.llvm@botech.co.uk>
Wed, 20 Mar 2019 22:02:09 +0000 (22:02 +0000)
committerTim Renouf <tpr.llvm@botech.co.uk>
Wed, 20 Mar 2019 22:02:09 +0000 (22:02 +0000)
My previous fix 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.

Differential Revision: https://reviews.llvm.org/D59613

Change-Id: Ie04a2aaae890dcd490f22c89edf9913a77ce070e

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356621 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
test/MC/AMDGPU/spurious-pal-metadata.s [new file with mode: 0644]

index abd1c3e69cb6944dfd177839e3ee72274641724d..694f7c6dc754f60011d4b9b7cf86854fb1b2250e 100644 (file)
@@ -518,6 +518,8 @@ static const char *getRegisterName(unsigned RegNum) {
 // 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 @@ void AMDGPUPALMetadata::toString(std::string &String) {
 }
 
 // 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 @@ const char *AMDGPUPALMetadata::getVendor() const {
 
 // 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.
index e676c28da7bf2076ff73695512779abb6e43a1fc..dbef2cc605dd7706d230880cdc71dab58ec375e7 100644 (file)
@@ -92,8 +92,8 @@ public:
 
   // 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.
diff --git a/test/MC/AMDGPU/spurious-pal-metadata.s b/test/MC/AMDGPU/spurious-pal-metadata.s
new file mode 100644 (file)
index 0000000..2d6a143
--- /dev/null
@@ -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