-
The function definition may list function notes which are used by
-various passes.
+
+
Function attributes are set to communicate additional information about
+ a function. Function attributes are considered to be part of the function,
+ not of the function type, so functions with different parameter attributes
+ can have the same function type.
+
+
Function attributes are simple keywords that follow the type specified. If
+ multiple attributes are needed, they are space separated. For
+ example:
-define void @f() notes(inline=Always) { ... }
-define void @f() notes(inline=Always,opt-size) { ... }
-define void @f() notes(inline=Never,opt-size) { ... }
-define void @f() notes(opt-size) { ... }
+define void @f() noinline { ... }
+define void @f() alwaysinline { ... }
+define void @f() alwaysinline optsize { ... }
+define void @f() optsize
-- inline=Always
-- This note requests inliner to inline this function irrespective of inlining
-size threshold for this function.
+- alwaysinline
+- This attribute requests inliner to inline this function irrespective of
+inlining size threshold for this function.
-- inline=Never
-- This note requests inliner to never inline this function in any situation.
-This note may not be used together with inline=Always note.
+- noinline
+- This attributes requests inliner to never inline this function in any
+situation. This attribute may not be used together with alwaysinline
+ attribute.
-- opt-size
-- This note suggests optimization passes and code generator passes to make
-choices that help reduce code size.
+- optsize
+- This attribute suggests optimization passes and code generator passes to
+make choices that help reduce code size.
+- noreturn
+- This function attribute indicates that the function never returns. This
+ indicates to LLVM that every call to this function should be treated as if
+ an unreachable instruction immediately followed the call.
+
+- nounwind
+- This function attribute indicates that no exceptions unwind out of the
+ function. Usually this is because the function makes no use of exceptions,
+ but it may also be that the function catches any exceptions thrown when
+ executing it.
+
+- readonly
+- This function attribute indicates that the function has no side-effects
+ except for producing a return value or throwing an exception. The value
+ returned must only depend on the function arguments and/or global variables.
+ It may use values obtained by dereferencing pointers.
+- readnone
+- A readnone function has the same restrictions as a readonly
+ function, but in addition it is not allowed to dereference any pointer arguments
+ or global variables.
-
Any notes that are not documented here are considered invalid notes.
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 19ff2bf4da5..3beda6e2892 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -149,16 +149,16 @@ public:
void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; }
- /// hasNote - Return true if this function has given note.
- bool hasNote(Attributes N) const {
- // Notes are stored at ~0 index in parameter attribute list
- return (paramHasAttr(~0, N));
+ /// hasFnAttr - Return true if this function has given attribute.
+ bool hasFnAttr(Attributes N) const {
+ // Function Attributes are stored at ~0 index
+ return AttributeList.paramHasAttr(~0U, N);
}
- /// setNotes - Set notes for this function
+ /// addFnAttr - Add function attributes
///
- void setNotes(const Attributes N) {
- // Notes are stored at ~0 index in parameter attribute list
+ void addFnAttr(const Attributes N) {
+ // Function Attributes are stored at ~0 index
addAttribute(~0, N);
}
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 16f4e158f57..39d62bf71cf 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -496,11 +496,9 @@ int LLLexer::LexIdentifier() {
KEYWORD("readnone", READNONE);
KEYWORD("readonly", READONLY);
- KEYWORD("notes", FNNOTE);
- KEYWORD("inline", INLINE);
- KEYWORD("always", ALWAYS);
- KEYWORD("never", NEVER);
- KEYWORD("opt_size", OPTIMIZEFORSIZE);
+ KEYWORD("noinline", NOINLINE);
+ KEYWORD("alwaysinline", ALWAYSINLINE);
+ KEYWORD("optsize", OPTSIZE);
KEYWORD("type", TYPE);
KEYWORD("opaque", OPAQUE);
diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs
index 59f18ddadb7..6caebc88a6e 100644
--- a/lib/AsmParser/llvmAsmParser.h.cvs
+++ b/lib/AsmParser/llvmAsmParser.h.cvs
@@ -189,14 +189,12 @@
READNONE = 405,
READONLY = 406,
GC = 407,
- FNNOTE = 408,
- INLINE = 409,
- ALWAYS = 410,
- NEVER = 411,
- OPTIMIZEFORSIZE = 412,
- DEFAULT = 413,
- HIDDEN = 414,
- PROTECTED = 415
+ OPTSIZE = 408,
+ NOINLINE = 409,
+ ALWAYSINLINE = 410,
+ DEFAULT = 411,
+ HIDDEN = 412,
+ PROTECTED = 413
};
#endif
/* Tokens. */
@@ -350,21 +348,19 @@
#define READNONE 405
#define READONLY 406
#define GC 407
-#define FNNOTE 408
-#define INLINE 409
-#define ALWAYS 410
-#define NEVER 411
-#define OPTIMIZEFORSIZE 412
-#define DEFAULT 413
-#define HIDDEN 414
-#define PROTECTED 415
+#define OPTSIZE 408
+#define NOINLINE 409
+#define ALWAYSINLINE 410
+#define DEFAULT 411
+#define HIDDEN 412
+#define PROTECTED 413
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 970 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
{
llvm::Module *ModuleVal;
llvm::Function *FunctionVal;
@@ -413,7 +409,7 @@ typedef union YYSTYPE
llvm::FCmpInst::Predicate FPredicate;
}
/* Line 1529 of yacc.c. */
-#line 417 "llvmAsmParser.tab.h"
+#line 413 "llvmAsmParser.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index a049cea8d85..fa86c1887e9 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1089,8 +1089,6 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%type