diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -9571,8 +9571,9 @@ 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`. Arguments: """""""""" @@ -9603,6 +9604,10 @@ 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` is meaningful only if the +target has assigned it a semantics. + If the returned pointer is used by :ref:`llvm.lifetime.start `, the returned object is initially dead. See :ref:`llvm.lifetime.start ` and diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3811,11 +3811,6 @@ void Verifier::visitAllocaInst(AllocaInst &AI) { SmallPtrSet 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(), diff --git a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll b/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll deleted file mode 100644 --- a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll +++ /dev/null @@ -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 -} diff --git a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll b/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll deleted file mode 100644 --- a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll +++ /dev/null @@ -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 -} diff --git a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll b/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll deleted file mode 100644 --- a/llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll +++ /dev/null @@ -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 = !{} diff --git a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll --- a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll +++ b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll @@ -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 @@ 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 ret void diff --git a/llvm/test/CodeGen/AMDGPU/invalid-alloca.ll b/llvm/test/CodeGen/AMDGPU/invalid-alloca.ll deleted file mode 100644 --- a/llvm/test/CodeGen/AMDGPU/invalid-alloca.ll +++ /dev/null @@ -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 -} -