diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index 5fdf6611e9a..f0c80673be1 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -112,8 +112,12 @@ public: bool hasSection() const { return !Section.empty(); } const std::string &getSection() const { return Section; } - void setSection(StringRef S) { Section = S; } - + void setSection(StringRef S) { + assert((getValueID() != Value::GlobalAliasVal || S.empty()) && + "GlobalAlias should not have a section!"); + Section = S; + } + /// If the usage is empty (except transitively dead constants), then this /// global value can be safely deleted since the destructor will /// delete the dead constants as well. diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index a70ea0f37b9..5ad96b2ce3a 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -57,6 +57,8 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) { } void GlobalValue::setAlignment(unsigned Align) { + assert((!isa(this) || !Align) && + "GlobalAlias should not have an alignment!"); assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Align <= MaximumAlignment && "Alignment is greater than MaximumAlignment!"); diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index f81260960e8..73496b4f55d 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -475,6 +475,8 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) { Assert1(GA.getType() == GA.getAliasee()->getType(), "Alias and aliasee types should match!", &GA); Assert1(!GA.hasUnnamedAddr(), "Alias cannot have unnamed_addr!", &GA); + Assert1(!GA.hasSection(), "Alias cannot have a section!", &GA); + Assert1(!GA.getAlignment(), "Alias connot have an alignment", &GA); const Constant *Aliasee = GA.getAliasee();