llvm.org GIT mirror llvm / 25456ef
Add the returns_twice attribute to LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141001 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
9 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
12611261 the ELF x86-64 abi, but it can be disabled for some compilation
12621262 units.
12631263
1264
returns_twice
1265
This attribute indicates that this function can return
1266 twice. The C setjmp is an example of such a function.
1267 The compiler disables some optimizations (like tail calls) in the caller of
1268 these functions.
12641269
12651270
12661271
6464 ///of alignment with +1 bias
6565 ///0 means unaligned (different from
6666 ///alignstack(1))
67 const Attributes Hotpatch = 1<<29; ///< Function should have special
68 ///'hotpatch' sequence in prologue
67 const Attributes ReturnsTwice = 1<<29; ///< Function can return twice
6968 const Attributes UWTable = 1<<30; ///< Function must be in a unwind
7069 ///table
7170 const Attributes NonLazyBind = 1U<<31; ///< Function is called early and/or
9291 const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
9392 NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
9493 NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment |
95 Hotpatch | UWTable | NonLazyBind;
94 UWTable | NonLazyBind | ReturnsTwice;
9695
9796 /// @brief Parameter attributes that do not apply to vararg call arguments.
9897 const Attributes VarArgsIncompatible = StructRet;
557557 KEYWORD(readnone);
558558 KEYWORD(readonly);
559559 KEYWORD(uwtable);
560 KEYWORD(returns_twice);
560561
561562 KEYWORD(inlinehint);
562563 KEYWORD(noinline);
910910 case lltok::kw_noreturn: Attrs |= Attribute::NoReturn; break;
911911 case lltok::kw_nounwind: Attrs |= Attribute::NoUnwind; break;
912912 case lltok::kw_uwtable: Attrs |= Attribute::UWTable; break;
913 case lltok::kw_returns_twice: Attrs |= Attribute::ReturnsTwice; break;
913914 case lltok::kw_noinline: Attrs |= Attribute::NoInline; break;
914915 case lltok::kw_readnone: Attrs |= Attribute::ReadNone; break;
915916 case lltok::kw_readonly: Attrs |= Attribute::ReadOnly; break;
921922 case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break;
922923 case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break;
923924 case lltok::kw_naked: Attrs |= Attribute::Naked; break;
924 case lltok::kw_hotpatch: Attrs |= Attribute::Hotpatch; break;
925925 case lltok::kw_nonlazybind: Attrs |= Attribute::NonLazyBind; break;
926926
927927 case lltok::kw_alignstack: {
8989 kw_readnone,
9090 kw_readonly,
9191 kw_uwtable,
92 kw_returns_twice,
9293
9394 kw_inlinehint,
9495 kw_noinline,
469469 HANDLE_ATTR(NoImplicitFloat);
470470 HANDLE_ATTR(Naked);
471471 HANDLE_ATTR(InlineHint);
472 HANDLE_ATTR(Hotpatch);
472 HANDLE_ATTR(ReturnsTwice);
473473 HANDLE_ATTR(UWTable);
474474 HANDLE_ATTR(NonLazyBind);
475475 #undef HANDLE_ATTR
3737 Result += "nounwind ";
3838 if (Attrs & Attribute::UWTable)
3939 Result += "uwtable ";
40 if (Attrs & Attribute::ReturnsTwice)
41 Result += "returns_twice ";
4042 if (Attrs & Attribute::InReg)
4143 Result += "inreg ";
4244 if (Attrs & Attribute::NoAlias)
7173 Result += "noimplicitfloat ";
7274 if (Attrs & Attribute::Naked)
7375 Result += "naked ";
74 if (Attrs & Attribute::Hotpatch)
75 Result += "hotpatch ";
7676 if (Attrs & Attribute::NonLazyBind)
7777 Result += "nonlazybind ";
7878 if (Attrs & Attribute::StackAlignment) {
4141 ret i32 %retval8
4242 }
4343
44 declare i32 @_setjmp(%struct.__jmp_buf_tag*)
44 declare i32 @_setjmp(%struct.__jmp_buf_tag*) returns_twice
4545
4646 declare void @g()
1010 ret void
1111 }
1212
13 declare i32 @setjmp(i32*)
13 declare i32 @setjmp(i32*) returns_twice
1414
1515 declare void @bar()