diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-06-14 22:48:13 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-06-14 22:48:13 +0000 |
commit | 0397729d3b8da4208660a163d18296b1a3bd32b8 (patch) | |
tree | 06128ec39f9c9771e28692b44a8ceb8edb41e338 /include/llvm/GlobalValue.h | |
parent | 312091ece3e7860cea0410318cf1e06cea75954e (diff) | |
download | llvm-0397729d3b8da4208660a163d18296b1a3bd32b8.tar.gz llvm-0397729d3b8da4208660a163d18296b1a3bd32b8.tar.bz2 llvm-0397729d3b8da4208660a163d18296b1a3bd32b8.tar.xz |
Implement the isSafeToDiscardIfUnused predicate and use it in globalopt and
globaldce. Globaldce was already removing linkonce globals, but globalopt was
not.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158476 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/GlobalValue.h')
-rw-r--r-- | include/llvm/GlobalValue.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index 81a11a4c92..8b969f3354 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -164,6 +164,12 @@ public: return Linkage == CommonLinkage; } + /// isDiscardableIfUnused - Whether the definition of this global may be + /// discarded if it is not used in its compilation unit. + static bool isDiscardableIfUnused(LinkageTypes Linkage) { + return isLinkOnceLinkage(Linkage) || isLocalLinkage(Linkage); + } + /// mayBeOverridden - Whether the definition of this global may be replaced /// by something non-equivalent at link time. For example, if a function has /// weak linkage then the code defining it may be replaced by different code. @@ -221,6 +227,10 @@ public: void setLinkage(LinkageTypes LT) { Linkage = LT; } LinkageTypes getLinkage() const { return Linkage; } + bool isDiscardableIfUnused() const { + return isDiscardableIfUnused(Linkage); + } + bool mayBeOverridden() const { return mayBeOverridden(Linkage); } bool isWeakForLinker() const { return isWeakForLinker(Linkage); } |