Allow addrspacecast in global aliases

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198349 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault 2014-01-02 20:55:01 +00:00
parent 0a3368cde5
commit ee60d39cdd
3 changed files with 11 additions and 2 deletions

View File

@ -237,7 +237,8 @@ GlobalValue *GlobalAlias::getAliasedGlobal() {
return GV; return GV;
ConstantExpr *CE = cast<ConstantExpr>(C); ConstantExpr *CE = cast<ConstantExpr>(C);
assert((CE->getOpcode() == Instruction::BitCast || assert((CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::AddrSpaceCast ||
CE->getOpcode() == Instruction::GetElementPtr) && CE->getOpcode() == Instruction::GetElementPtr) &&
"Unsupported aliasee"); "Unsupported aliasee");

View File

@ -550,9 +550,11 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) {
ConstantExpr *CE = dyn_cast<ConstantExpr>(Aliasee); ConstantExpr *CE = dyn_cast<ConstantExpr>(Aliasee);
Assert1(CE && Assert1(CE &&
(CE->getOpcode() == Instruction::BitCast || (CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::AddrSpaceCast ||
CE->getOpcode() == Instruction::GetElementPtr) && CE->getOpcode() == Instruction::GetElementPtr) &&
isa<GlobalValue>(CE->getOperand(0)), isa<GlobalValue>(CE->getOperand(0)),
"Aliasee should be either GlobalValue or bitcast of GlobalValue", "Aliasee should be either GlobalValue, bitcast or "
"addrspacecast of GlobalValue",
&GA); &GA);
if (CE->getOpcode() == Instruction::BitCast) { if (CE->getOpcode() == Instruction::BitCast) {

View File

@ -0,0 +1,6 @@
; RUN: llvm-as -disable-output %s
; Test that global aliases are allowed to be constant addrspacecast
@i = internal addrspace(1) global i8 42
@ia = alias internal i8 addrspace(2)* addrspacecast (i8 addrspace(1)* @i to i8 addrspace(2)*)