[llvm] d32fa59 - [XCOFF] Don't emit non-external labels in the symbol table and handle MCSA_LGlobal
David Tenty via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 27 10:37:35 PST 2020
Author: David Tenty
Date: 2020-02-27T13:37:13-05:00
New Revision: d32fa59fa007ba53b8453f96a5661b149e4715c7
URL: https://github.com/llvm/llvm-project/commit/d32fa59fa007ba53b8453f96a5661b149e4715c7
DIFF: https://github.com/llvm/llvm-project/commit/d32fa59fa007ba53b8453f96a5661b149e4715c7.diff
LOG: [XCOFF] Don't emit non-external labels in the symbol table and handle MCSA_LGlobal
Summary:
We need to handle the MCSA_LGlobal case in emitSymbolAttribute for functions marked internal in the IR so that the
appropriate storage class is emitted on the function descriptor csect. As part of this we need to make sure that external
labels are not emitted into the symbol table, so we don't emit the descriptor label in the object writing path.
Reviewers: jasonliu, DiggerLin, hubert.reinterpretcast
Reviewed By: jasonliu
Subscribers: Xiangling_L, wuzish, nemanjai, hiraditya, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74968
Added:
llvm/test/CodeGen/PowerPC/aix-internal.ll
Modified:
llvm/lib/MC/MCXCOFFStreamer.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp
index 2e66730e171c..8c08e6780ecb 100644
--- a/llvm/lib/MC/MCXCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -10,12 +10,13 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/MC/MCXCOFFStreamer.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSymbolXCOFF.h"
-#include "llvm/MC/MCXCOFFStreamer.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -37,6 +38,10 @@ bool MCXCOFFStreamer::emitSymbolAttribute(MCSymbol *Sym,
Symbol->setStorageClass(XCOFF::C_EXT);
Symbol->setExternal(true);
break;
+ case MCSA_LGlobal:
+ Symbol->setStorageClass(XCOFF::C_HIDEXT);
+ Symbol->setExternal(true);
+ break;
default:
report_fatal_error("Not implemented yet.");
}
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 17ec6dd06a8b..bd9229d0d0e3 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -353,6 +353,10 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
if (XSym == ContainingCsect->getQualNameSymbol())
continue;
+ // Only put a label into the symbol table when it is an external label.
+ if (!XSym->isExternal())
+ continue;
+
assert(SectionMap.find(ContainingCsect) != SectionMap.end() &&
"Expected containing csect to exist in map");
// Lookup the containing csect and add the symbol to it.
diff --git a/llvm/test/CodeGen/PowerPC/aix-internal.ll b/llvm/test/CodeGen/PowerPC/aix-internal.ll
new file mode 100644
index 000000000000..1a1fb78dfaf7
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/aix-internal.ll
@@ -0,0 +1,38 @@
+; RUN: llc -mtriple powerpc-ibm-aix -verify-machineinstrs -mcpu=pwr4 \
+; RUN: -filetype=obj -o %t.o < %s
+; RUN: llvm-readobj --syms %t.o | FileCheck %s
+; RUN: not --crash llc -mtriple powerpc64-ibm-aix -verify-machineinstrs -mcpu=pwr4 \
+; RUN: -filetype=obj -o %t.o < %s 2>&1 | FileCheck --check-prefix=64-CHECK %s
+
+define internal i32 @foo() {
+ ret i32 1
+}
+
+; CHECK: Symbol {
+; CHECK: Name: .foo
+; CHECK-NEXT: Value (RelocatableAddress):
+; CHECK-NEXT: Section: .text
+; CHECK-NEXT: Type: 0x0
+; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B)
+
+; CHECK: Symbol {
+; CHECK-NEXT: Index: [[#INDX:]]
+; CHECK-NEXT: Name: foo
+; CHECK-NEXT: Value (RelocatableAddress):
+; CHECK-NEXT: Section: .data
+; CHECK-NEXT: Type: 0x0
+; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B)
+; CHECK-NEXT: NumberOfAuxEntries: 1
+; CHECK-NEXT: CSECT Auxiliary Entry {
+; CHECK-NEXT: Index: [[#INDX+1]]
+; CHECK-NEXT: SectionLen: 12
+; CHECK-NEXT: ParameterHashIndex:
+; CHECK-NEXT: TypeChkSectNum:
+; CHECK-NEXT: SymbolAlignmentLog2:
+; CHECK-NEXT: SymbolType: XTY_SD (0x1)
+; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA)
+
+; Make sure no label is emitted.
+; CHECK-NOT: Name: foo
+
+;64-CHECK: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
index 09b1a4a33912..b9efa55cdab9 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
@@ -52,18 +52,15 @@ entry:
;CHECKOBJ-NEXT: 4: 4e 80 00 20 blr
;CHECKOBJ-NEXT: ...{{[[:space:]] *}}
;CHECKOBJ-NEXT: 00000010 .rodata:
-;CHECKOBJ-NEXT: 10: 40 00 00 00 bdnzf 0, .+0
-;CHECKOBJ-NEXT: 14: 00 00 00 32 <unknown>
+;CHECKOBJ-NEXT: 10: 40 00 00 00
+;CHECKOBJ-NEXT: 14: 00 00 00 32
;CHECKOBJ-NEXT: ...{{[[:space:]] *}}
-;CHECKOBJ-NEXT: 00000030 .L__const.main.cnst16:
-;CHECKOBJ-NEXT: 30: 40 00 00 00 bdnzf 0, .+0
-;CHECKOBJ-NEXT: 34: 00 00 00 16 <unknown>
+;CHECKOBJ-SAME: 30: 40 00 00 00
+;CHECKOBJ-NEXT: 34: 00 00 00 16
;CHECKOBJ-NEXT: ...{{[[:space:]] *}}
-;CHECKOBJ-NEXT: 00000040 .L__const.main.cnst8:
-;CHECKOBJ-NEXT: 40: 40 00 00 08 bdnzf 0, .+8
-;CHECKOBJ-NEXT: 44: 00 00 00 00 <unknown>{{[[:space:]] *}}
-;CHECKOBJ-NEXT: 00000048 .L__const.main.cnst4:
-;CHECKOBJ-NEXT: 48: 40 08 00 00 bdnzf 8, .+0
+;CHECKOBJ-SAME: 40: 40 00 00 08
+;CHECKOBJ-NEXT: 44: 00 00 00 00
+;CHECKOBJ-NEXT: 48: 40 08 00 00
;CHECKSYM: Symbol {{[{][[:space:]] *}}Index: [[#Index:]]{{[[:space:]] *}}Name: .rodata
@@ -84,83 +81,3 @@ entry:
;CHECKSYM-NEXT: StabSectNum: 0x0
;CHECKSYM-NEXT: }
;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: Symbol {
-;CHECKSYM-NEXT: Index: [[#Index+2]]
-;CHECKSYM-NEXT: Name: .L__const.main.cnst32
-;CHECKSYM-NEXT: Value (RelocatableAddress): 0x10
-;CHECKSYM-NEXT: Section: .text
-;CHECKSYM-NEXT: Type: 0x0
-;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B)
-;CHECKSYM-NEXT: NumberOfAuxEntries: 1
-;CHECKSYM-NEXT: CSECT Auxiliary Entry {
-;CHECKSYM-NEXT: Index: [[#Index+3]]
-;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]]
-;CHECKSYM-NEXT: ParameterHashIndex: 0x0
-;CHECKSYM-NEXT: TypeChkSectNum: 0x0
-;CHECKSYM-NEXT: SymbolAlignmentLog2: 0
-;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2)
-;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1)
-;CHECKSYM-NEXT: StabInfoIndex: 0x0
-;CHECKSYM-NEXT: StabSectNum: 0x0
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: Symbol {
-;CHECKSYM-NEXT: Index: [[#Index+4]]
-;CHECKSYM-NEXT: Name: .L__const.main.cnst16
-;CHECKSYM-NEXT: Value (RelocatableAddress): 0x30
-;CHECKSYM-NEXT: Section: .text
-;CHECKSYM-NEXT: Type: 0x0
-;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B)
-;CHECKSYM-NEXT: NumberOfAuxEntries: 1
-;CHECKSYM-NEXT: CSECT Auxiliary Entry {
-;CHECKSYM-NEXT: Index: [[#Index+5]]
-;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]]
-;CHECKSYM-NEXT: ParameterHashIndex: 0x0
-;CHECKSYM-NEXT: TypeChkSectNum: 0x0
-;CHECKSYM-NEXT: SymbolAlignmentLog2: 0
-;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2)
-;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1)
-;CHECKSYM-NEXT: StabInfoIndex: 0x0
-;CHECKSYM-NEXT: StabSectNum: 0x0
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: Symbol {
-;CHECKSYM-NEXT: Index: [[#Index+6]]
-;CHECKSYM-NEXT: Name: .L__const.main.cnst8
-;CHECKSYM-NEXT: Value (RelocatableAddress): 0x40
-;CHECKSYM-NEXT: Section: .text
-;CHECKSYM-NEXT: Type: 0x0
-;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B)
-;CHECKSYM-NEXT: NumberOfAuxEntries: 1
-;CHECKSYM-NEXT: CSECT Auxiliary Entry {
-;CHECKSYM-NEXT: Index: [[#Index+7]]
-;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]]
-;CHECKSYM-NEXT: ParameterHashIndex: 0x0
-;CHECKSYM-NEXT: TypeChkSectNum: 0x0
-;CHECKSYM-NEXT: SymbolAlignmentLog2: 0
-;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2)
-;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1)
-;CHECKSYM-NEXT: StabInfoIndex: 0x0
-;CHECKSYM-NEXT: StabSectNum: 0x0
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: Symbol {
-;CHECKSYM-NEXT: Index: [[#Index+8]]
-;CHECKSYM-NEXT: Name: .L__const.main.cnst4
-;CHECKSYM-NEXT: Value (RelocatableAddress): 0x48
-;CHECKSYM-NEXT: Section: .text
-;CHECKSYM-NEXT: Type: 0x0
-;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B)
-;CHECKSYM-NEXT: NumberOfAuxEntries: 1
-;CHECKSYM-NEXT: CSECT Auxiliary Entry {
-;CHECKSYM-NEXT: Index: [[#Index+9]]
-;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]]
-;CHECKSYM-NEXT: ParameterHashIndex: 0x0
-;CHECKSYM-NEXT: TypeChkSectNum: 0x0
-;CHECKSYM-NEXT: SymbolAlignmentLog2: 0
-;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2)
-;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1)
-;CHECKSYM-NEXT: StabInfoIndex: 0x0
-;CHECKSYM-NEXT: StabSectNum: 0x0
-;CHECKSYM-NEXT: }
-;CHECKSYM-NEXT: }
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
index db622a97d068..6a53d65e8238 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
@@ -78,9 +78,6 @@ entry:
; CHECKOBJ-NEXT: 28: 68 65 6c 6c
; CHECKOBJ-NEXT: 2c: 6f 20 77 6f
; CHECKOBJ-NEXT: 30: 72 6c 64 21
-; CHECKOBJ-NEXT: 34: 0a 00 61 62 {{.*}}{{[[:space:]] *}}
-; CHECKOBJ-NEXT: 00000036 .L.str:
-; CHECKOBJ-NEXT: 36: 61 62 63 64
-; CHECKOBJ-NEXT: 3a: 65 66 67 68
-; CHECKOBJ-NEXT: 3e: 00
-; CHECKOBJ-NEXT: 3f: 00
+; CHECKOBJ-NEXT: 34: 0a 00 61 62
+; CHECKOBJ-NEXT: 38: 63 64 65 66
+; CHECKOBJ-NEXT: 3c: 67 68 00 00
More information about the llvm-commits
mailing list