inalloca: Fix incorrect example IR and remove LangRef warning

The LangRef warning wasn't formatting the way I intended it to anyway.

Surprisingly inalloca appears to work, even when optimizations are
enabled.  We generate very bad code for it, but we can self-host and run
lots of big tests.

llvm-svn: 204888
This commit is contained in:
Reid Kleckner 2014-03-27 01:32:22 +00:00
parent 9ba00f19f0
commit 5602f267b5
2 changed files with 13 additions and 16 deletions

View File

@ -31,41 +31,40 @@ Intended Usage
==============
The example below is the intended LLVM IR lowering for some C++ code
that passes a default-constructed ``Foo`` object to ``g`` in the 32-bit
Microsoft C++ ABI.
that passes two default-constructed ``Foo`` objects to ``g`` in the
32-bit Microsoft C++ ABI.
.. code-block:: c++
// Foo is non-trivial.
struct Foo { int a, b; Foo(); ~Foo(); Foo(const &Foo); };
struct Foo { int a, b; Foo(); ~Foo(); Foo(const Foo &); };
void g(Foo a, Foo b);
void f() {
f(1, Foo(), 3);
g(Foo(), Foo());
}
.. code-block:: llvm
%struct.Foo = type { i32, i32 }
%callframe.f = type { %struct.Foo, %struct.Foo }
declare void @Foo_ctor(%Foo* %this)
declare void @Foo_dtor(%Foo* %this)
declare void @g(%Foo* inalloca %memargs)
%callframe.f = type <{ %struct.Foo, %struct.Foo }>
declare void @Foo_ctor(%struct.Foo* %this)
declare void @Foo_dtor(%struct.Foo* %this)
declare void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
define void @f() {
entry:
%base = call i8* @llvm.stacksave()
%memargs = alloca %callframe.f
%b = getelementptr %callframe.f*, i32 0
%a = getelementptr %callframe.f*, i32 1
%memargs = alloca <{ %struct.Foo, %struct.Foo }>
%b = getelementptr <{ %struct.Foo, %struct.Foo }>*, i32 1
call void @Foo_ctor(%struct.Foo* %b)
; If a's ctor throws, we must destruct b.
invoke void @Foo_ctor(%struct.Foo* %arg1)
%a = getelementptr <{ %struct.Foo, %struct.Foo }>*, i32 0
invoke void @Foo_ctor(%struct.Foo* %a)
to label %invoke.cont unwind %invoke.unwind
invoke.cont:
store i32 1, i32* %arg0
call void @g(%callframe.f* inalloca %memargs)
call void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
call void @llvm.stackrestore(i8* %base)
...

View File

@ -765,8 +765,6 @@ Currently, only the following parameter attributes are defined:
``inalloca``
.. Warning:: This feature is unstable and not fully implemented.
The ``inalloca`` argument attribute allows the caller to take the
address of outgoing stack arguments. An ``inalloca`` argument must
be a pointer to stack memory produced by an ``alloca`` instruction.