diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-07 23:00:22 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-07 23:00:22 +0000 |
commit | e60adfdbd0d8ee91d6b48d29381d68acf192b385 (patch) | |
tree | d3266b0faa5c8fde2b39dbdd53a22a4aee011a4f | |
parent | b80de1012ae346786dbb019ed6bdf8ba8820d8ab (diff) | |
download | bcm5719-llvm-e60adfdbd0d8ee91d6b48d29381d68acf192b385.tar.gz bcm5719-llvm-e60adfdbd0d8ee91d6b48d29381d68acf192b385.zip |
GlobalValue: Assert symbols with local linkage have default visibility
The change to ExtractGV.cpp has no functionality change except to avoid
the asserts. Existing testcases already cover this, so I didn't add a
new one.
llvm-svn: 208264
-rw-r--r-- | llvm/include/llvm/IR/GlobalValue.h | 12 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/ExtractGV.cpp | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index 84343001112..51b9380ec1c 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -93,7 +93,11 @@ public: bool hasProtectedVisibility() const { return Visibility == ProtectedVisibility; } - void setVisibility(VisibilityTypes V) { Visibility = V; } + void setVisibility(VisibilityTypes V) { + assert((!hasLocalLinkage() || V == DefaultVisibility) && + "local linkage requires default visibility"); + Visibility = V; + } DLLStorageClassTypes getDLLStorageClass() const { return DLLStorageClassTypes(DllStorageClass); @@ -195,7 +199,11 @@ public: bool hasExternalWeakLinkage() const { return isExternalWeakLinkage(Linkage); } bool hasCommonLinkage() const { return isCommonLinkage(Linkage); } - void setLinkage(LinkageTypes LT) { Linkage = LT; } + void setLinkage(LinkageTypes LT) { + assert((!isLocalLinkage(LT) || hasDefaultVisibility()) && + "local linkage requires default visibility"); + Linkage = LT; + } LinkageTypes getLinkage() const { return Linkage; } bool isDiscardableIfUnused() const { diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp index 408713a2c24..40ec9fa8c1d 100644 --- a/llvm/lib/Transforms/IPO/ExtractGV.cpp +++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp @@ -27,11 +27,10 @@ using namespace llvm; /// the split module remain valid. static void makeVisible(GlobalValue &GV, bool Delete) { bool Local = GV.hasLocalLinkage(); - if (Local) - GV.setVisibility(GlobalValue::HiddenVisibility); - if (Local || Delete) { GV.setLinkage(GlobalValue::ExternalLinkage); + if (Local) + GV.setVisibility(GlobalValue::HiddenVisibility); return; } |