[PATCH] D51209: AMDGPU: Default to hidden visibility
Matt Arsenault via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 24 02:23:52 PDT 2018
arsenm created this revision.
arsenm added reviewers: t-tye, kzhuravl, yaxunl.
Herald added subscribers: sunfish, aheejin, tpr, dstuttard, nhaehnle, wdng, jvesely, dschuff.
Object linking isn't supported, so it's not useful
to emit default visibility. Default visibility requires
relocations we don't yet support for functions compiled
in another translation unit.
WebAssembly already does this, although they insert these
arguments in a different place for some reason.
https://reviews.llvm.org/D51209
Files:
lib/Driver/ToolChains/AMDGPU.cpp
lib/Driver/ToolChains/AMDGPU.h
test/Driver/amdgpu-visibility.cl
Index: test/Driver/amdgpu-visibility.cl
===================================================================
--- /dev/null
+++ test/Driver/amdgpu-visibility.cl
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility=protected %s 2>&1 | FileCheck -check-prefix=OVERRIDE-PROTECTED %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility-ms-compat %s 2>&1 | FileCheck -check-prefix=OVERRIDE-MS %s
+
+// DEFAULT: "-fvisibility" "hidden"
+// OVERRIDE-PROTECTED: "-fvisibility" "protected"
+// OVERRIDE-MS: "-fvisibility" "hidden" "-ftype-visibility" "default"
Index: lib/Driver/ToolChains/AMDGPU.h
===================================================================
--- lib/Driver/ToolChains/AMDGPU.h
+++ lib/Driver/ToolChains/AMDGPU.h
@@ -61,6 +61,10 @@
llvm::opt::DerivedArgList *
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const override;
+
+ void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadKind) const override;
};
} // end namespace toolchains
Index: lib/Driver/ToolChains/AMDGPU.cpp
===================================================================
--- lib/Driver/ToolChains/AMDGPU.cpp
+++ lib/Driver/ToolChains/AMDGPU.cpp
@@ -98,3 +98,16 @@
return DAL;
}
+
+void AMDGPUToolChain::addClangTargetOptions(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadingKind) const {
+ // Default to "hidden" visibility, as object level linking will not be
+ // supported for the forseeable future.
+ if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
+ options::OPT_fvisibility_ms_compat)) {
+ CC1Args.push_back("-fvisibility");
+ CC1Args.push_back("hidden");
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51209.162350.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180824/2779546c/attachment.bin>
More information about the cfe-commits
mailing list