[llvm] r198349 - Allow addrspacecast in global aliases

Owen Anderson resistor at mac.com
Tue Jan 14 16:20:13 PST 2014


I don't know Matt's intent here, but some GPUs support accessing local memory via a memory mapping inside global memory, in addition to via direct access.  This has the nice benefit of still allowing direct access (which might be more efficient) while simplifying the programming model by allowing precompiled functions with pointer parameters not to have to be specialized for each address space.

--Owen

On Jan 14, 2014, at 04:15 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:

Sorry I missed this before.

Why do you need this? Aliases are just another name for a given
position, so it seems strange to have the same position being in two
address spaces.

How do you see this interacting with the proposed solution for
http://llvm.org/bugs/show_bug.cgi?id=10367?

On 2 January 2014 12:55, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
Author: arsenm
Date: Thu Jan 2 14:55:01 2014
New Revision: 198349
URL: http://llvm.org/viewvc/llvm-project?rev=198349&view=rev
Log:
Allow addrspacecast in global aliases
Added:
llvm/trunk/test/Assembler/addrspacecast-alias.ll
Modified:
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=198349&r1=198348&r2=198349&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Thu Jan 2 14:55:01 2014
@@ -237,7 +237,8 @@ GlobalValue *GlobalAlias::getAliasedGlob
return GV;
ConstantExpr *CE = cast<ConstantExpr>(C);
- assert((CE->getOpcode() == Instruction::BitCast ||
+ assert((CE->getOpcode() == Instruction::BitCast ||
+ CE->getOpcode() == Instruction::AddrSpaceCast ||
CE->getOpcode() == Instruction::GetElementPtr) &&
"Unsupported aliasee");
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=198349&r1=198348&r2=198349&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Jan 2 14:55:01 2014
@@ -550,9 +550,11 @@ void Verifier::visitGlobalAlias(GlobalAl
ConstantExpr *CE = dyn_cast<ConstantExpr>(Aliasee);
Assert1(CE &&
(CE->getOpcode() == Instruction::BitCast ||
+ CE->getOpcode() == Instruction::AddrSpaceCast ||
CE->getOpcode() == Instruction::GetElementPtr) &&
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);
if (CE->getOpcode() == Instruction::BitCast) {
Added: llvm/trunk/test/Assembler/addrspacecast-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/addrspacecast-alias.ll?rev=198349&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/addrspacecast-alias.ll (added)
+++ llvm/trunk/test/Assembler/addrspacecast-alias.ll Thu Jan 2 14:55:01 2014
@@ -0,0 +1,6 @@
+; RUN: llvm-as -disable-output %s
+
+; Test that global aliases are allowed to be constant addrspacecast
+
+ at i = internal addrspace(1) global i8 42
+ at ia = alias internal i8 addrspace(2)* addrspacecast (i8 addrspace(1)* @i to i8 addrspace(2)*)
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140115/d79cbf0a/attachment.html>


More information about the llvm-commits mailing list