diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2019-06-07 19:10:08 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2019-06-07 19:10:08 +0000 |
commit | cfa017d306c8fd588037a2c16ba2d645a52547d7 (patch) | |
tree | a966d6bc30f9a54e7bd26704a6e97ecdbc4ec90d /lib | |
parent | 14c82ea52be56c98faccc93db67eb7ea5d613e4a (diff) | |
download | clang-cfa017d306c8fd588037a2c16ba2d645a52547d7.tar.gz |
Driver, IRGen: Set partitions on GlobalValues according to -fsymbol-partition flag.
Differential Revision: https://reviews.llvm.org/D62636
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 9 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 5 | ||||
-rw-r--r-- | lib/CodeGen/ItaniumCXXABI.cpp | 3 | ||||
-rw-r--r-- | lib/Driver/ToolChains/Clang.cpp | 8 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 2 |
5 files changed, 20 insertions, 7 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index e79eb71b79..bd44a493a2 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -875,19 +875,20 @@ void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV, void CodeGenModule::setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const { setDLLImportDLLExport(GV, GD); - setGlobalVisibilityAndLocal(GV, dyn_cast<NamedDecl>(GD.getDecl())); + setGVPropertiesAux(GV, dyn_cast<NamedDecl>(GD.getDecl())); } void CodeGenModule::setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const { setDLLImportDLLExport(GV, D); - setGlobalVisibilityAndLocal(GV, D); + setGVPropertiesAux(GV, D); } -void CodeGenModule::setGlobalVisibilityAndLocal(llvm::GlobalValue *GV, - const NamedDecl *D) const { +void CodeGenModule::setGVPropertiesAux(llvm::GlobalValue *GV, + const NamedDecl *D) const { setGlobalVisibility(GV, D); setDSOLocal(GV); + GV->setPartition(CodeGenOpts.SymbolPartition); } static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) { diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 6ab454fe6d..8c1bc0777d 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -759,9 +759,6 @@ public: /// Set the visibility for the given LLVM GlobalValue. void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; - void setGlobalVisibilityAndLocal(llvm::GlobalValue *GV, - const NamedDecl *D) const; - void setDSOLocal(llvm::GlobalValue *GV) const; void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const; @@ -771,6 +768,8 @@ public: void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const; void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const; + void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const; + /// Set the TLS mode for the given LLVM GlobalValue for the thread-local /// variable declaration D. void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const; diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 3fac8d60fd..bd399b25c3 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -3420,6 +3420,9 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo( TypeName->setDLLStorageClass(DLLStorageClass); GV->setDLLStorageClass(DLLStorageClass); + TypeName->setPartition(CGM.getCodeGenOpts().SymbolPartition); + GV->setPartition(CGM.getCodeGenOpts().SymbolPartition); + return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy); } diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 650f73d36f..29bdaf067f 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -5410,6 +5410,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, TC.useIntegratedAs())) CmdArgs.push_back("-faddrsig"); + if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) { + std::string Str = A->getAsString(Args); + if (!TC.getTriple().isOSBinFormatELF()) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << Str << TC.getTripleString(); + CmdArgs.push_back(Args.MakeArgString(Str)); + } + // Add the "-o out -x type src.c" flags last. This is done primarily to make // the -cc1 command easier to edit when reproducing compiler crashes. if (Output.getType() == types::TY_Dependencies) { diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ca0f2fc845..1b475dc037 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1345,6 +1345,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ); + Opts.SymbolPartition = Args.getLastArgValue(OPT_fsymbol_partition_EQ); + return Success; } |