llvm.org GIT mirror llvm / 9a419f6
Change ForceSizeOpt attribute into MinSize attribute git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167020 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 7 years ago
11 changed file(s) with 56 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
5757 ///< 0 means unaligned different from align 1
5858 AlwaysInline, ///< inline=always
5959 ByVal, ///< Pass structure by value
60 ForceSizeOpt, ///< Function must be optimized for size first
6160 InlineHint, ///< Source said inlining was desirable
6261 InReg, ///< Force argument to be passed in register
62 MinSize, ///< Function must be optimized for size first
6363 Naked, ///< Naked function
6464 Nest, ///< Nested function static chain
6565 NoAlias, ///< Considered to not alias after call
153153 hasAttribute(Attributes::NonLazyBind) ||
154154 hasAttribute(Attributes::ReturnsTwice) ||
155155 hasAttribute(Attributes::AddressSafety) ||
156 hasAttribute(Attributes::ForceSizeOpt);
156 hasAttribute(Attributes::MinSize);
157157 }
158158
159159 bool operator==(const Attributes &A) const {
265265 .removeAttribute(Attributes::NonLazyBind)
266266 .removeAttribute(Attributes::ReturnsTwice)
267267 .removeAttribute(Attributes::AddressSafety)
268 .removeAttribute(Attributes::ForceSizeOpt);
268 .removeAttribute(Attributes::MinSize);
269269 }
270270
271271 uint64_t Raw() const { return Bits; }
557557 KEYWORD(naked);
558558 KEYWORD(nonlazybind);
559559 KEYWORD(address_safety);
560 KEYWORD(forcesizeopt);
560 KEYWORD(minsize);
561561
562562 KEYWORD(type);
563563 KEYWORD(opaque);
952952 case lltok::kw_naked: B.addAttribute(Attributes::Naked); break;
953953 case lltok::kw_nonlazybind: B.addAttribute(Attributes::NonLazyBind); break;
954954 case lltok::kw_address_safety: B.addAttribute(Attributes::AddressSafety); break;
955 case lltok::kw_forcesizeopt: B.addAttribute(Attributes::ForceSizeOpt); break;
955 case lltok::kw_minsize: B.addAttribute(Attributes::MinSize); break;
956956
957957 case lltok::kw_alignstack: {
958958 unsigned Alignment;
10111011 case lltok::kw_nonlazybind:
10121012 case lltok::kw_returns_twice:
10131013 case lltok::kw_address_safety:
1014 case lltok::kw_forcesizeopt:
1014 case lltok::kw_minsize:
10151015 if (AttrKind != 2)
10161016 HaveError |= Error(AttrLoc, "invalid use of function-only attribute");
10171017 break;
109109 kw_naked,
110110 kw_nonlazybind,
111111 kw_address_safety,
112 kw_forcesizeopt,
112 kw_minsize,
113113
114114 kw_type,
115115 kw_opaque,
15931593
15941594 // FIXME: handle tail calls differently.
15951595 unsigned CallOpc;
1596 bool HasForceSizeAttr = MF.getFunction()->getFnAttributes().
1597 hasAttribute(Attributes::ForceSizeOpt);
1596 bool HasMinSizeAttr = MF.getFunction()->getFnAttributes().
1597 hasAttribute(Attributes::MinSize);
15981598 if (Subtarget->isThumb()) {
15991599 if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps())
16001600 CallOpc = ARMISD::CALL_NOLINK;
16011601 else if (doesNotRet && isDirect && !isARMFunc &&
16021602 Subtarget->hasRAS() && !Subtarget->isThumb1Only() &&
16031603 // Emit regular call when code size is the priority
1604 !HasForceSizeAttr)
1604 !HasMinSizeAttr)
16051605 // "mov lr, pc; b _foo" to avoid confusing the RSP
16061606 CallOpc = ARMISD::CALL_NOLINK;
16071607 else
16111611 CallOpc = ARMISD::CALL_NOLINK;
16121612 } else if (doesNotRet && isDirect && Subtarget->hasRAS() &&
16131613 // Emit regular call when code size is the priority
1614 !HasForceSizeAttr)
1614 !HasMinSizeAttr)
16151615 // "mov lr, pc; b _foo" to avoid confusing the RSP
16161616 CallOpc = ARMISD::CALL_NOLINK;
16171617 else
506506 HANDLE_ATTR(ReturnsTwice);
507507 HANDLE_ATTR(UWTable);
508508 HANDLE_ATTR(NonLazyBind);
509 HANDLE_ATTR(MinSize);
509510 #undef HANDLE_ATTR
510511 if (attrs.hasAttribute(Attributes::StackAlignment))
511512 Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";
200200 Result += "nonlazybind ";
201201 if (hasAttribute(Attributes::AddressSafety))
202202 Result += "address_safety ";
203 if (hasAttribute(Attributes::ForceSizeOpt))
204 Result += "forcesizeopt ";
203 if (hasAttribute(Attributes::MinSize))
204 Result += "minsize ";
205205 if (hasAttribute(Attributes::StackAlignment)) {
206206 Result += "alignstack(";
207207 Result += utostr(getStackAlignment());
325325 case Attributes::UWTable: return 1 << 30;
326326 case Attributes::NonLazyBind: return 1U << 31;
327327 case Attributes::AddressSafety: return 1ULL << 32;
328 case Attributes::ForceSizeOpt: return 1ULL << 33;
328 case Attributes::MinSize: return 1ULL << 33;
329329 }
330330 llvm_unreachable("Unsupported attribute type");
331331 }
+0
-34
test/CodeGen/ARM/call-noret-forsize.ll less more
None ; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=ARM
1 ; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=swift | FileCheck %s -check-prefix=SWIFT
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2
3 ; rdar://12348580
4
5 define void @t1() noreturn forcesizeopt nounwind ssp {
6 entry:
7 ; ARM: t1:
8 ; ARM: bl _bar
9
10 ; SWIFT: t1:
11 ; SWIFT: bl _bar
12
13 ; T2: t1:
14 ; T2: blx _bar
15 tail call void @bar() noreturn nounwind
16 unreachable
17 }
18
19 define void @t2() noreturn forcesizeopt nounwind ssp {
20 entry:
21 ; ARM: t2:
22 ; ARM: bl _t1
23
24 ; SWIFT: t2:
25 ; SWIFT: bl _t1
26
27 ; T2: t2:
28 ; T2: bl _t1
29 tail call void @t1() noreturn nounwind
30 unreachable
31 }
32
33 declare void @bar() noreturn
0 ; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=ARM
1 ; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=swift | FileCheck %s -check-prefix=SWIFT
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2
3 ; rdar://12348580
4
5 define void @t1() noreturn minsize nounwind ssp {
6 entry:
7 ; ARM: t1:
8 ; ARM: bl _bar
9
10 ; SWIFT: t1:
11 ; SWIFT: bl _bar
12
13 ; T2: t1:
14 ; T2: blx _bar
15 tail call void @bar() noreturn nounwind
16 unreachable
17 }
18
19 define void @t2() noreturn minsize nounwind ssp {
20 entry:
21 ; ARM: t2:
22 ; ARM: bl _t1
23
24 ; SWIFT: t2:
25 ; SWIFT: bl _t1
26
27 ; T2: t2:
28 ; T2: bl _t1
29 tail call void @t1() noreturn nounwind
30 unreachable
31 }
32
33 declare void @bar() noreturn
+0
-7
test/Feature/forceoptsize_attr.ll less more
None ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
1
2 define void @test1() forcesizeopt {
3 ; CHECK: define void @test1() forcesizeopt
4 ret void
5 }
6
0 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
1
2 define void @test1() minsize {
3 ; CHECK: define void @test1() minsize
4 ret void
5 }
6