llvm.org GIT mirror llvm / 2ce2122
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 Reid Kleckner 5 years ago
2 changed file(s) with 13 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
3030 ==============
3131
3232 The example below is the intended LLVM IR lowering for some C++ code
33 that passes a default-constructed ``Foo`` object to ``g`` in the 32-bit
34 Microsoft C++ ABI.
33 that passes two default-constructed ``Foo`` objects to ``g`` in the
34 32-bit Microsoft C++ ABI.
3535
3636 .. code-block:: c++
3737
3838 // Foo is non-trivial.
39 struct Foo { int a, b; Foo(); ~Foo(); Foo(const &Foo); };
39 struct Foo { int a, b; Foo(); ~Foo(); Foo(const Foo &); };
4040 void g(Foo a, Foo b);
4141 void f() {
42 f(1, Foo(), 3);
42 g(Foo(), Foo());
4343 }
4444
4545 .. code-block:: llvm
4646
4747 %struct.Foo = type { i32, i32 }
48 %callframe.f = type { %struct.Foo, %struct.Foo }
49 declare void @Foo_ctor(%Foo* %this)
50 declare void @Foo_dtor(%Foo* %this)
51 declare void @g(%Foo* inalloca %memargs)
48 %callframe.f = type <{ %struct.Foo, %struct.Foo }>
49 declare void @Foo_ctor(%struct.Foo* %this)
50 declare void @Foo_dtor(%struct.Foo* %this)
51 declare void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
5252
5353 define void @f() {
5454 entry:
5555 %base = call i8* @llvm.stacksave()
56 %memargs = alloca %callframe.f
57 %b = getelementptr %callframe.f*, i32 0
58 %a = getelementptr %callframe.f*, i32 1
56 %memargs = alloca <{ %struct.Foo, %struct.Foo }>
57 %b = getelementptr <{ %struct.Foo, %struct.Foo }>*, i32 1
5958 call void @Foo_ctor(%struct.Foo* %b)
6059
6160 ; If a's ctor throws, we must destruct b.
62 invoke void @Foo_ctor(%struct.Foo* %arg1)
61 %a = getelementptr <{ %struct.Foo, %struct.Foo }>*, i32 0
62 invoke void @Foo_ctor(%struct.Foo* %a)
6363 to label %invoke.cont unwind %invoke.unwind
6464
6565 invoke.cont:
66 store i32 1, i32* %arg0
67 call void @g(%callframe.f* inalloca %memargs)
66 call void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
6867 call void @llvm.stackrestore(i8* %base)
6968 ...
7069
763763 .. _attr_inalloca:
764764
765765 ``inalloca``
766
767 .. Warning:: This feature is unstable and not fully implemented.
768766
769767 The ``inalloca`` argument attribute allows the caller to take the
770768 address of outgoing stack arguments. An ``inalloca`` argument must