mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197645 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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 }
|
||||
|
7
test/CodeGen/CPP/attributes.ll
Normal file
7
test/CodeGen/CPP/attributes.ll
Normal file
@@ -0,0 +1,7 @@
|
||||
; RUN: llc < %s -march=cpp | FileCheck %s
|
||||
|
||||
define void @f1(i8* byval, i8* inalloca) {
|
||||
; CHECK: ByVal
|
||||
; CHECK: InAlloca
|
||||
ret void
|
||||
}
|
19
test/Verifier/inalloca1.ll
Normal file
19
test/Verifier/inalloca1.ll
Normal file
@@ -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
|
21
test/Verifier/inalloca2.ll
Normal file
21
test/Verifier/inalloca2.ll
Normal file
@@ -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
|
||||
}
|
Reference in New Issue
Block a user