diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -94,6 +94,8 @@ bool getFunctionSections(); Optional getExplicitFunctionSections(); +bool getNoXCOFFVisibility(); + std::string getBBSections(); unsigned getTLSSize(); diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/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 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 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(); diff --git a/llvm/test/CodeGen/PowerPC/aix-no-xcoff-visibility.ll b/llvm/test/CodeGen/PowerPC/aix-no-xcoff-visibility.ll new file mode 100644 --- /dev/null +++ b/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 + +@foo_p = global void ()* @zoo_extern_h, align 4 +@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