From 2ce21220d8318494f1d3da8d0bcdefca670a2fcd Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 27 Mar 2014 01:32:22 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204888 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/InAlloca.rst | 27 +++++++++++++-------------- docs/LangRef.rst | 2 -- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/docs/InAlloca.rst b/docs/InAlloca.rst index a5df96da772..b3ec86a0540 100644 --- a/docs/InAlloca.rst +++ b/docs/InAlloca.rst @@ -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) ... diff --git a/docs/LangRef.rst b/docs/LangRef.rst index dfbb22ffb9f..adf3266b029 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -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. -- 2.34.1