diff options
| author | Reid Kleckner <reid@kleckner.net> | 2013-12-19 02:14:12 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2013-12-19 02:14:12 +0000 |
| commit | a534a381304efc038276f426a756f5c56834bbc5 (patch) | |
| tree | 0e73ad0bfb6ba29e5473a7ce1d4d91bb68175557 /llvm/test | |
| parent | b353ee18086227b3a4192a970cdbced5358003f5 (diff) | |
| download | bcm5719-llvm-a534a381304efc038276f426a756f5c56834bbc5.tar.gz bcm5719-llvm-a534a381304efc038276f426a756f5c56834bbc5.zip | |
Begin adding docs and IR-level support for the inalloca attribute
The inalloca attribute is designed to support passing C++ objects by
value in the Microsoft C++ ABI. It behaves the same as byval, except
that it always implies that the argument is in memory and that the bytes
are never copied. This attribute allows the caller to take the address
of an outgoing argument's memory and execute arbitrary code to store
into it.
This patch adds basic IR support, docs, and verification. It does not
attempt to implement any lowering or fix any possibly broken transforms.
When this patch lands, a complete description of this feature should
appear at http://llvm.org/docs/InAlloca.html .
Differential Revision: http://llvm-reviews.chandlerc.com/D2173
llvm-svn: 197645
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Bitcode/attributes.ll | 5 | ||||
| -rw-r--r-- | llvm/test/CodeGen/CPP/attributes.ll | 7 | ||||
| -rw-r--r-- | llvm/test/Verifier/inalloca1.ll | 19 | ||||
| -rw-r--r-- | llvm/test/Verifier/inalloca2.ll | 21 |
4 files changed, 52 insertions, 0 deletions
diff --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll index 1789878e9f5..545f1cbb28c 100644 --- a/llvm/test/Bitcode/attributes.ll +++ b/llvm/test/Bitcode/attributes.ll @@ -213,6 +213,11 @@ define void @f35() optnone noinline ret void; } +define void @f36(i8* inalloca) { +; CHECK: define void @f36(i8* inalloca) { + ret void +} + ; CHECK: attributes #0 = { noreturn } ; CHECK: attributes #1 = { nounwind } ; CHECK: attributes #2 = { readnone } diff --git a/llvm/test/CodeGen/CPP/attributes.ll b/llvm/test/CodeGen/CPP/attributes.ll new file mode 100644 index 00000000000..3dab617d80b --- /dev/null +++ b/llvm/test/CodeGen/CPP/attributes.ll @@ -0,0 +1,7 @@ +; RUN: llc < %s -march=cpp | FileCheck %s + +define void @f1(i8* byval, i8* inalloca) { +; CHECK: ByVal +; CHECK: InAlloca + ret void +} diff --git a/llvm/test/Verifier/inalloca1.ll b/llvm/test/Verifier/inalloca1.ll new file mode 100644 index 00000000000..9408c95ee31 --- /dev/null +++ b/llvm/test/Verifier/inalloca1.ll @@ -0,0 +1,19 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s + +declare void @a(i64* byval inalloca %p) +; CHECK: Attributes {{.*}} are incompatible + +declare void @b(i64* inreg inalloca %p) +; CHECK: Attributes {{.*}} are incompatible + +declare void @c(i64* sret inalloca %p) +; CHECK: Attributes {{.*}} are incompatible + +declare void @d(i64* nest inalloca %p) +; CHECK: Attributes {{.*}} are incompatible + +declare void @e(i64* readonly inalloca %p) +; CHECK: Attributes {{.*}} are incompatible + +declare void @f(void ()* inalloca %p) +; CHECK: do not support unsized types diff --git a/llvm/test/Verifier/inalloca2.ll b/llvm/test/Verifier/inalloca2.ll new file mode 100644 index 00000000000..acdd9ae3a66 --- /dev/null +++ b/llvm/test/Verifier/inalloca2.ll @@ -0,0 +1,21 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s + +declare void @doit(i64* inalloca %a) + +define void @a() { +entry: + %a = alloca [2 x i32] + %b = bitcast [2 x i32]* %a to i64* + call void @doit(i64* inalloca %b) +; CHECK: Inalloca argument is not an alloca! + ret void +} + +define void @b() { +entry: + %a = alloca i64 + call void @doit(i64* inalloca %a) + call void @doit(i64* inalloca %a) +; CHECK: Allocas can be used at most once with inalloca! + ret void +} |

