[PATCH] D88234: add new llc option -no-xcoff-visibility

Digger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 08:42:13 PDT 2020


DiggerLin created this revision.
DiggerLin added reviewers: jasonliu, daltenty, hubert.reinterpretcast, sfertile.
Herald added subscribers: llvm-commits, hiraditya, nemanjai.
Herald added a project: LLVM.
DiggerLin requested review of this revision.

when there is a -no-xcoff-visibility for llc , 
Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in xcoff object file


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88234

Files:
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/test/CodeGen/PowerPC/aix-no-xcoff-visibility.ll


Index: llvm/test/CodeGen/PowerPC/aix-no-xcoff-visibility.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-no-xcoff-visibility.ll
@@ -0,0 +1,48 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN:     -mattr=-altivec  < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN:     -mattr=-altivec -no-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=NOVISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN:     -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN:     -mattr=-altivec -no-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=NOVISIBILITY-ASM %s
+
+ at foo_p = global void ()* @zoo_extern_h, align 4
+ at b = protected global i32 0, align 4
+
+define hidden void @foo_h(i32* %p) {
+entry:
+  %p.addr = alloca i32*, align 4
+  store i32* %p, i32** %p.addr, align 4
+  %0 = load i32*, i32** %p.addr, align 4
+  %1 = load i32, i32* %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %0, align 4
+  ret void
+}
+
+declare hidden void @zoo_extern_h()
+
+define protected void @bar() {
+entry:
+  call void @foo_h(i32* @b)
+  %0 = load void ()*, void ()** @foo_p, align 4
+  call void %0()
+  ret void
+}
+
+; VISIBILITY-ASM: .globl  foo_h[DS],hidden
+; VISIBILITY-ASM: .globl  .foo_h,hidden
+; VISIBILITY-ASM: .globl  bar[DS],protected
+; VISIBILITY-ASM: .globl  .bar,protected
+; VISIBILITY-ASM: .globl  b,protected
+
+; NOVISIBILITY-ASM: .globl  foo_h[DS]
+; NOVISIBILITY-ASM: .globl  .foo_h
+; NOVISIBILITY-ASM: .globl  bar[DS]
+; NOVISIBILITY-ASM: .globl  .bar
+; NOVISIBILITY-ASM: .globl  b
Index: llvm/lib/CodeGen/CommandFlags.cpp
===================================================================
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -74,6 +74,7 @@
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
+CGOPT(bool, NoXCOFFVisibility)
 CGOPT(std::string, BBSections)
 CGOPT(unsigned, TLSSize)
 CGOPT(bool, EmulatedTLS)
@@ -333,6 +334,13 @@
       cl::init(false));
   CGBINDOPT(FunctionSections);
 
+  static cl::opt<bool> NoXCOFFVisibility(
+      "no-xcoff-visibility",
+      cl::desc("Not emit the visibility attribute for asm in AIX OS or give "
+               "all symbols 'unspecified' visibility in xcoff object file"),
+      cl::init(false));
+  CGBINDOPT(NoXCOFFVisibility);
+
   static cl::opt<std::string> BBSections(
       "basic-block-sections",
       cl::desc("Emit basic blocks into separate sections"),
@@ -479,6 +487,7 @@
   Options.RelaxELFRelocations = getRelaxELFRelocations();
   Options.DataSections = getDataSections();
   Options.FunctionSections = getFunctionSections();
+  Options.NoXCOFFVisibility = getNoXCOFFVisibility();
   Options.BBSections = getBBSectionsMode(Options);
   Options.UniqueSectionNames = getUniqueSectionNames();
   Options.UniqueBasicBlockSectionNames = getUniqueBasicBlockSectionNames();
Index: llvm/include/llvm/CodeGen/CommandFlags.h
===================================================================
--- llvm/include/llvm/CodeGen/CommandFlags.h
+++ llvm/include/llvm/CodeGen/CommandFlags.h
@@ -94,6 +94,8 @@
 bool getFunctionSections();
 Optional<bool> getExplicitFunctionSections();
 
+bool getNoXCOFFVisibility();
+
 std::string getBBSections();
 
 unsigned getTLSSize();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88234.294077.patch
Type: text/x-patch
Size: 3623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200924/94f796e0/attachment.bin>


More information about the llvm-commits mailing list