1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

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).

llvm-svn: 201354
This commit is contained in:
Rafael Espindola 2014-02-13 18:26:41 +00:00
parent 1cd702e570
commit e01239e65c
3 changed files with 10 additions and 2 deletions

View File

@ -112,7 +112,11 @@ 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

View File

@ -57,6 +57,8 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
}
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!");

View File

@ -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();