mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[IR][Verifier] Relax restriction on alloca address spaces
In the WebAssembly target, we would like to allow alloca in two address spaces. The alloca instruction already has an address space argument, but the verifier asserts that the address space of an alloca is the default alloca address space from the datalayout. This patch removes this restriction. Targets that would like to impose additional restrictions should do so via target-specific verification passes. Differential Revision: https://reviews.llvm.org/D101045
This commit is contained in:
parent
88aa158bd7
commit
107b591be0
@ -9571,8 +9571,9 @@ Overview:
|
||||
|
||||
The '``alloca``' instruction allocates memory on the stack frame of the
|
||||
currently executing function, to be automatically released when this
|
||||
function returns to its caller. The object is always allocated in the
|
||||
address space for allocas indicated in the datalayout.
|
||||
function returns to its caller. If the address space is not explicitly
|
||||
specified, the object is allocated in the alloca address space from the
|
||||
:ref:`datalayout string<langref_datalayout>`.
|
||||
|
||||
Arguments:
|
||||
""""""""""
|
||||
@ -9603,6 +9604,10 @@ the memory is reclaimed. Allocating zero bytes is legal, but the returned
|
||||
pointer may not be unique. The order in which memory is allocated (ie.,
|
||||
which way the stack grows) is not specified.
|
||||
|
||||
Note that '``alloca``' outside of the alloca address space from the
|
||||
:ref:`datalayout string<langref_datalayout>` is meaningful only if the
|
||||
target has assigned it a semantics.
|
||||
|
||||
If the returned pointer is used by :ref:`llvm.lifetime.start <int_lifestart>`,
|
||||
the returned object is initially dead.
|
||||
See :ref:`llvm.lifetime.start <int_lifestart>` and
|
||||
|
@ -3811,11 +3811,6 @@ void Verifier::verifySwiftErrorValue(const Value *SwiftErrorVal) {
|
||||
|
||||
void Verifier::visitAllocaInst(AllocaInst &AI) {
|
||||
SmallPtrSet<Type*, 4> Visited;
|
||||
PointerType *PTy = AI.getType();
|
||||
// TODO: Relax this restriction?
|
||||
Assert(PTy->getAddressSpace() == DL.getAllocaAddrSpace(),
|
||||
"Allocation instruction pointer not in the stack address space!",
|
||||
&AI);
|
||||
Assert(AI.getAllocatedType()->isSized(&Visited),
|
||||
"Cannot allocate unsized type", &AI);
|
||||
Assert(AI.getArraySize()->getType()->isIntegerTy(),
|
||||
|
@ -1,11 +0,0 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "A1"
|
||||
|
||||
; CHECK: Allocation instruction pointer not in the stack address space!
|
||||
; CHECK-NEXT: %alloca_scalar_no_align = alloca i32, align 4, addrspace(2)
|
||||
|
||||
define void @use_alloca() {
|
||||
%alloca_scalar_no_align = alloca i32, addrspace(2)
|
||||
ret void
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "A1"
|
||||
|
||||
; CHECK: Allocation instruction pointer not in the stack address space!
|
||||
; CHECK-NEXT: %alloca_scalar_no_align = alloca i32, align 4, addrspace(2)
|
||||
|
||||
define void @use_alloca() {
|
||||
%alloca_scalar_no_align = alloca i32, align 4, addrspace(2)
|
||||
ret void
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "A1"
|
||||
|
||||
; CHECK: Allocation instruction pointer not in the stack address space!
|
||||
; CHECK-NEXT: %alloca_scalar_no_align = alloca i32, align 4, addrspace(2), !foo !0
|
||||
|
||||
define void @use_alloca() {
|
||||
%alloca_scalar_no_align = alloca i32, align 4, addrspace(2), !foo !0
|
||||
ret void
|
||||
}
|
||||
|
||||
!0 = !{}
|
@ -1,7 +1,7 @@
|
||||
; RUN: llvm-as < %s -o %t.bc -data-layout=A5 2>&1 | FileCheck -check-prefixes=ALL,AS %s
|
||||
; RUN: llvm-dis < %t.bc | FileCheck -check-prefixes=ALL,DIS %s
|
||||
; RUN: opt < %s -S -data-layout=A5 2>&1 | FileCheck -check-prefixes=ALL,AS %s
|
||||
; RUN: opt < %t.bc -S | FileCheck -check-prefixes=ALL,DIS %s
|
||||
; RUN: llvm-as < %s -o %t.bc -data-layout=A5 2>&1 | FileCheck -check-prefixes=AS %s
|
||||
; RUN: llvm-dis < %t.bc | FileCheck -check-prefixes=DIS %s
|
||||
; RUN: opt < %s -S -data-layout=A5 2>&1 | FileCheck -check-prefixes=AS %s
|
||||
; RUN: opt < %t.bc -S | FileCheck -check-prefixes=DIS %s
|
||||
|
||||
define void @foo() {
|
||||
entry:
|
||||
@ -12,7 +12,6 @@ entry:
|
||||
metadata i8* undef,
|
||||
metadata !DILocalVariable(scope: !1),
|
||||
metadata !DIExpression())
|
||||
; ALL-NOT: Allocation instruction pointer not in the stack address space!
|
||||
; AS: llvm.dbg.value intrinsic requires a !dbg attachment
|
||||
; AS: warning: ignoring invalid debug info in <stdin>
|
||||
ret void
|
||||
|
@ -1,20 +0,0 @@
|
||||
; RUN: not llvm-as -data-layout=A5 < %s 2>&1 | FileCheck -check-prefixes=COMMON,AS %s
|
||||
; RUN: not llc -mtriple amdgcn-amd-amdhsa < %s 2>&1 | FileCheck -check-prefixes=COMMON,LLC %s
|
||||
; RUN: llvm-as < %s | not llc -mtriple amdgcn-amd-amdhsa 2>&1 | FileCheck -check-prefixes=MISMATCH %s
|
||||
; RUN: not opt -data-layout=A5 -S < %s 2>&1 | FileCheck -check-prefixes=COMMON,OPT %s
|
||||
; RUN: llvm-as < %s | not opt -data-layout=A5 2>&1 | FileCheck -check-prefixes=MISMATCH %s
|
||||
|
||||
; AS: assembly parsed, but does not verify as correct!
|
||||
; COMMON: Allocation instruction pointer not in the stack address space!
|
||||
; COMMON: %tmp = alloca i32
|
||||
; MISMATCH: Explicit load/store type does not match pointee type of pointer operand
|
||||
; LLC: error: {{.*}}input module cannot be verified
|
||||
; OPT: error: input module is broken!
|
||||
|
||||
define amdgpu_kernel void @test() {
|
||||
%tmp = alloca i32
|
||||
%tmp2 = alloca i32*
|
||||
store i32* %tmp, i32** %tmp2
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user