llvm.org GIT mirror llvm / 5768bb8
Add function attribute 'optnone'. This function attribute indicates that the function is not optimized by any optimization or code generator passes with the exception of interprocedural optimization passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189101 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 6 years ago
16 changed file(s) with 72 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
878878 This function attribute indicates that the function never returns
879879 with an unwind or exceptional control flow. If the function does
880880 unwind, its runtime behavior is undefined.
881 ``optnone``
882 This function attribute indicates that the function is not optimized
883 by any optimization or code generator passes with the
884 exception of interprocedural optimization passes.
885 This attribute cannot be used together with the ``alwaysinline``
886 attribute; this attribute is also incompatible
887 with the ``minsize`` attribute and the ``optsize`` attribute.
888
889 The inliner should never inline this function in any situation.
890 Only functions with the ``alwaysinline`` attribute are valid
891 candidates for inlining inside the body of this function.
881892 ``optsize``
882893 This attribute suggests that optimization passes and code generator
883894 passes make choices that keep the code size of this function low,
367367 ATTR_KIND_UW_TABLE = 33,
368368 ATTR_KIND_Z_EXT = 34,
369369 ATTR_KIND_BUILTIN = 35,
370 ATTR_KIND_COLD = 36
370 ATTR_KIND_COLD = 36,
371 ATTR_KIND_OPTIMIZE_NONE = 37
371372 };
372373
373374 } // End bitc namespace
8787 NoReturn, ///< Mark the function as not returning
8888 NoUnwind, ///< Function doesn't unwind stack
8989 OptimizeForSize, ///< opt_size
90 OptimizeNone, ///< Function must not be optimized.
9091 ReadNone, ///< Function does not access memory
9192 ReadOnly, ///< Function only reads from memory
9293 Returned, ///< Return value is always equal to this argument
164164 a temporary measure until the API/ABI impact to the C API is understood
165165 and the path forward agreed upon.
166166 LLVMAddressSafety = 1ULL << 32,
167 LLVMStackProtectStrongAttribute = 1ULL<<33
168 LLVMCold = 1ULL << 34
167 LLVMStackProtectStrongAttribute = 1ULL<<33,
168 LLVMCold = 1ULL << 34,
169 LLVMOptimizeNone = 1ULL << 35
169170 */
170171 } LLVMAttribute;
171172
582582 KEYWORD(noredzone);
583583 KEYWORD(noreturn);
584584 KEYWORD(nounwind);
585 KEYWORD(optnone);
585586 KEYWORD(optsize);
586587 KEYWORD(readnone);
587588 KEYWORD(readonly);
921921 case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break;
922922 case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break;
923923 case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
924 case lltok::kw_optnone: B.addAttribute(Attribute::OptimizeNone); break;
924925 case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break;
925926 case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break;
926927 case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break;
11791180 case lltok::kw_noredzone:
11801181 case lltok::kw_noreturn:
11811182 case lltok::kw_nounwind:
1183 case lltok::kw_optnone:
11821184 case lltok::kw_optsize:
11831185 case lltok::kw_returns_twice:
11841186 case lltok::kw_sanitize_address:
12371239 case lltok::kw_noredzone:
12381240 case lltok::kw_noreturn:
12391241 case lltok::kw_nounwind:
1242 case lltok::kw_optnone:
12401243 case lltok::kw_optsize:
12411244 case lltok::kw_returns_twice:
12421245 case lltok::kw_sanitize_address:
113113 kw_noredzone,
114114 kw_noreturn,
115115 kw_nounwind,
116 kw_optnone,
116117 kw_optsize,
117118 kw_readnone,
118119 kw_readonly,
571571 return false;
572572 case bitc::ATTR_KIND_OPTIMIZE_FOR_SIZE:
573573 *Kind = Attribute::OptimizeForSize;
574 return false;
575 case bitc::ATTR_KIND_OPTIMIZE_NONE:
576 *Kind = Attribute::OptimizeNone;
574577 return false;
575578 case bitc::ATTR_KIND_READ_NONE:
576579 *Kind = Attribute::ReadNone;
204204 return bitc::ATTR_KIND_NO_UNWIND;
205205 case Attribute::OptimizeForSize:
206206 return bitc::ATTR_KIND_OPTIMIZE_FOR_SIZE;
207 case Attribute::OptimizeNone:
208 return bitc::ATTR_KIND_OPTIMIZE_NONE;
207209 case Attribute::ReadNone:
208210 return bitc::ATTR_KIND_READ_NONE;
209211 case Attribute::ReadOnly:
195195 return "noreturn";
196196 if (hasAttribute(Attribute::NoUnwind))
197197 return "nounwind";
198 if (hasAttribute(Attribute::OptimizeNone))
199 return "optnone";
198200 if (hasAttribute(Attribute::OptimizeForSize))
199201 return "optsize";
200202 if (hasAttribute(Attribute::ReadNone))
380382 case Attribute::Returned: return 1ULL << 39;
381383 case Attribute::Cold: return 1ULL << 40;
382384 case Attribute::Builtin: return 1ULL << 41;
385 case Attribute::OptimizeNone: return 1ULL << 42;
383386 }
384387 llvm_unreachable("Unsupported attribute type");
385388 }
750750 I->getKindAsEnum() == Attribute::NoDuplicate ||
751751 I->getKindAsEnum() == Attribute::Builtin ||
752752 I->getKindAsEnum() == Attribute::NoBuiltin ||
753 I->getKindAsEnum() == Attribute::Cold) {
753 I->getKindAsEnum() == Attribute::Cold ||
754 I->getKindAsEnum() == Attribute::OptimizeNone) {
754755 if (!isFunction) {
755756 CheckFailed("Attribute '" + I->getAsString() +
756757 "' only applies to functions!", V);
896897 Attrs.hasAttribute(AttributeSet::FunctionIndex,
897898 Attribute::AlwaysInline)),
898899 "Attributes 'noinline and alwaysinline' are incompatible!", V);
900
901 if (Attrs.hasAttribute(AttributeSet::FunctionIndex,
902 Attribute::OptimizeNone)) {
903 Assert1(!Attrs.hasAttribute(AttributeSet::FunctionIndex,
904 Attribute::AlwaysInline),
905 "Attributes 'alwaysinline and optnone' are incompatible!", V);
906
907 Assert1(!Attrs.hasAttribute(AttributeSet::FunctionIndex,
908 Attribute::OptimizeForSize),
909 "Attributes 'optsize and optnone' are incompatible!", V);
910
911 Assert1(!Attrs.hasAttribute(AttributeSet::FunctionIndex,
912 Attribute::MinSize),
913 "Attributes 'minsize and optnone' are incompatible!", V);
914 }
899915 }
900916
901917 void Verifier::VerifyBitcastType(const Value *V, Type *DestTy, Type *SrcTy) {
496496 HANDLE_ATTR(ReadOnly);
497497 HANDLE_ATTR(NoInline);
498498 HANDLE_ATTR(AlwaysInline);
499 HANDLE_ATTR(OptimizeNone);
499500 HANDLE_ATTR(OptimizeForSize);
500501 HANDLE_ATTR(StackProtect);
501502 HANDLE_ATTR(StackProtectReq);
202202 ; CHECK: define void @f34()
203203 {
204204 call void @nobuiltin() nobuiltin
205 ; CHECK: call void @nobuiltin() #23
205 ; CHECK: call void @nobuiltin() #24
206 ret void;
207 }
208
209 define void @f35() optnone
210 ; CHECK: define void @f35() #23
211 {
206212 ret void;
207213 }
208214
229235 ; CHECK: attributes #20 = { "cpu"="cortex-a8" }
230236 ; CHECK: attributes #21 = { sspstrong }
231237 ; CHECK: attributes #22 = { minsize }
232 ; CHECK: attributes #23 = { nobuiltin }
238 ; CHECK: attributes #23 = { optnone }
239 ; CHECK: attributes #24 = { nobuiltin }
240
0 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
1
2 ; Check for the presence of attribute noopt in the disassembly.
3
4 ; CHECK: @foo() #0
5 define void @foo() #0 {
6 ret void
7 }
8
9 ; CHECK: attributes #0 = { optnone }
10 attributes #0 = { optnone }
11
8484 noredzone
8585 noreturn
8686 nounwind
87 optnone
8788 optsize
8889 readnone
8990 readonly
4747 syn keyword llvmKeyword localdynamic localexec minsize module monotonic
4848 syn keyword llvmKeyword msp430_intrcc naked nest noalias nocapture
4949 syn keyword llvmKeyword noimplicitfloat noinline nonlazybind noredzone noreturn
50 syn keyword llvmKeyword nounwind optsize personality private protected
50 syn keyword llvmKeyword nounwind optnone optsize personality private protected
5151 syn keyword llvmKeyword ptx_device ptx_kernel readnone readonly release
5252 syn keyword llvmKeyword returns_twice sanitize_thread sanitize_memory
5353 syn keyword llvmKeyword section seq_cst sideeffect signext singlethread