[PATCH] D43186: [AsmPrinter] Allow lowerConstant() to strip address space casts
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 06:16:47 PST 2018
krisb created this revision.
Herald added a subscriber: llvm-commits.
lowerConstant() doesn't expect AddrSpaceCast in an input expression
which can occur if IR is compiled for a SPIR target.
This patch allows lowerConstant() to strip address space casts here if they
haven't been resolved.
Repository:
rL LLVM
https://reviews.llvm.org/D43186
Files:
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
test/CodeGen/X86/constant-with-addrspace-cast.ll
Index: test/CodeGen/X86/constant-with-addrspace-cast.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/constant-with-addrspace-cast.ll
@@ -0,0 +1,8 @@
+; RUN: llc -filetype=asm -mtriple x86_64 < %s
+
+; Check that the code below successfully compiled without getting
+; "LLVM ERROR: Unsupported expression in static initializer: addrspacecast"
+
+ at __block_literal_global = external addrspace(1) constant { i32, i32, i8 addrspace(4)* }, align 4
+
+ at block_A = addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*), align 4
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2028,6 +2028,7 @@
// is reasonable to treat their delta as a 32-bit value.
LLVM_FALLTHROUGH;
case Instruction::BitCast:
+ case Instruction::AddrSpaceCast:
return lowerConstant(CE->getOperand(0));
case Instruction::IntToPtr: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43186.133847.patch
Type: text/x-patch
Size: 1249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180212/e444ca6b/attachment.bin>
More information about the llvm-commits
mailing list