[llvm] r201354 - Check that GlobalAliases don't have section or alignment.
Rafael Espindola
rafael.espindola at gmail.com
Thu Feb 13 10:26:42 PST 2014
Author: rafael
Date: Thu Feb 13 12:26:41 2014
New Revision: 201354
URL: http://llvm.org/viewvc/llvm-project?rev=201354&view=rev
Log:
Check that GlobalAliases don't have section or alignment.
An alias is always in the section of its aliasee and has the same alignment
(since it has the same address).
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=201354&r1=201353&r2=201354&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Thu Feb 13 12:26:41 2014
@@ -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.
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=201354&r1=201353&r2=201354&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Thu Feb 13 12:26:41 2014
@@ -57,6 +57,8 @@ void GlobalValue::copyAttributesFrom(con
}
void GlobalValue::setAlignment(unsigned Align) {
+ assert((!isa<GlobalAlias>(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!");
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=201354&r1=201353&r2=201354&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Feb 13 12:26:41 2014
@@ -475,6 +475,8 @@ void Verifier::visitGlobalAlias(const Gl
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();
More information about the llvm-commits
mailing list