diff --git a/docs/LangRef.rst b/docs/LangRef.rst index a3b9c956552..4c2de632ed3 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -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`. 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` 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/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 7eea7116b99..fb5c1a3088b 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -3811,11 +3811,6 @@ void Verifier::verifySwiftErrorValue(const Value *SwiftErrorVal) { 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/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll b/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll deleted file mode 100644 index 3ab5890a144..00000000000 --- a/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/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll b/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll deleted file mode 100644 index 9f1b91aae61..00000000000 --- a/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/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll b/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll deleted file mode 100644 index 1e9d3cb959c..00000000000 --- a/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/test/Assembler/drop-debug-info-nonzero-alloca.ll b/test/Assembler/drop-debug-info-nonzero-alloca.ll index 01446dfb653..f2d401675bd 100644 --- a/test/Assembler/drop-debug-info-nonzero-alloca.ll +++ b/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 @@ 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 ret void diff --git a/test/CodeGen/AMDGPU/invalid-alloca.ll b/test/CodeGen/AMDGPU/invalid-alloca.ll deleted file mode 100644 index dd1e568d2a2..00000000000 --- a/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 -} -