diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-18 23:41:44 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-18 23:41:44 +0000 |
commit | c0ce9eca0b709b16e9c1d0f1686d4e2314af02b8 (patch) | |
tree | 71ed27a2daa450a3c47f64aac713d573e5751d7c /clang/lib/CodeGen/TargetInfo.cpp | |
parent | 2ea8639696ce7f3f732cc2f3607a1aa794eca86f (diff) | |
download | bcm5719-llvm-c0ce9eca0b709b16e9c1d0f1686d4e2314af02b8.tar.gz bcm5719-llvm-c0ce9eca0b709b16e9c1d0f1686d4e2314af02b8.zip |
Put more stuff in the comdat used for variables with static init.
Clang can already handle
-------------------------------------------
struct S {
static const int x;
};
template<typename T> struct U {
static const int k;
};
template<typename T> const int U<T>::k = T::x;
const int S::x = 42;
extern const int *f();
const int *g() { return &U<S>::k; }
int main() {
return *f() + U<S>::k;
}
const int *f() { return &U<S>::k; }
-------------------------------------------
since r217264 which puts the .inint_array section in the same COMDAT
as the variable.
This patch allows the linker to more easily delete some dead code and data by
putting the guard variable and init function in the same COMDAT.
llvm-svn: 218089
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 9bf1dbbd0d8..cca825c1c56 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -6868,6 +6868,14 @@ static bool getTypeString(SmallStringEnc &Enc, const Decl *D, // Driver code //===----------------------------------------------------------------------===// +const llvm::Triple &CodeGenModule::getTriple() const { + return getTarget().getTriple(); +} + +bool CodeGenModule::supportsCOMDAT() const { + return !getTriple().isOSBinFormatMachO(); +} + const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { if (TheTargetCodeGenInfo) return *TheTargetCodeGenInfo; |