mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[clang][IR] Add support for leaf attribute
This patch adds support for leaf attribute as an optimization hint in Clang/LLVM. Differential Revision: https://reviews.llvm.org/D90275
This commit is contained in:
parent
56023bebcf
commit
196c46aa87
@ -653,6 +653,7 @@ enum AttributeKindCodes {
|
||||
ATTR_KIND_NOUNDEF = 68,
|
||||
ATTR_KIND_BYREF = 69,
|
||||
ATTR_KIND_MUSTPROGRESS = 70,
|
||||
ATTR_KIND_NO_CALLBACK = 71,
|
||||
};
|
||||
|
||||
enum ComdatSelectionKindCodes {
|
||||
|
@ -103,6 +103,9 @@ def NoAlias : EnumAttr<"noalias">;
|
||||
/// Callee isn't recognized as a builtin.
|
||||
def NoBuiltin : EnumAttr<"nobuiltin">;
|
||||
|
||||
/// Function cannot enter into caller's translation unit.
|
||||
def NoCallback : EnumAttr<"nocallback">;
|
||||
|
||||
/// Function creates no aliases of pointer.
|
||||
def NoCapture : EnumAttr<"nocapture">;
|
||||
|
||||
|
@ -653,6 +653,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(nest);
|
||||
KEYWORD(noalias);
|
||||
KEYWORD(nobuiltin);
|
||||
KEYWORD(nocallback);
|
||||
KEYWORD(nocapture);
|
||||
KEYWORD(noduplicate);
|
||||
KEYWORD(nofree);
|
||||
|
@ -1353,6 +1353,9 @@ bool LLParser::parseFnAttributeValuePairs(AttrBuilder &B,
|
||||
break;
|
||||
case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
|
||||
case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break;
|
||||
case lltok::kw_nocallback:
|
||||
B.addAttribute(Attribute::NoCallback);
|
||||
break;
|
||||
case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break;
|
||||
case lltok::kw_nofree: B.addAttribute(Attribute::NoFree); break;
|
||||
case lltok::kw_noimplicitfloat:
|
||||
|
@ -200,6 +200,7 @@ enum Kind {
|
||||
kw_noalias,
|
||||
kw_noundef,
|
||||
kw_nobuiltin,
|
||||
kw_nocallback,
|
||||
kw_nocapture,
|
||||
kw_noduplicate,
|
||||
kw_nofree,
|
||||
|
@ -1433,6 +1433,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
|
||||
return Attribute::NoAlias;
|
||||
case bitc::ATTR_KIND_NO_BUILTIN:
|
||||
return Attribute::NoBuiltin;
|
||||
case bitc::ATTR_KIND_NO_CALLBACK:
|
||||
return Attribute::NoCallback;
|
||||
case bitc::ATTR_KIND_NO_CAPTURE:
|
||||
return Attribute::NoCapture;
|
||||
case bitc::ATTR_KIND_NO_DUPLICATE:
|
||||
|
@ -646,6 +646,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
|
||||
return bitc::ATTR_KIND_NO_ALIAS;
|
||||
case Attribute::NoBuiltin:
|
||||
return bitc::ATTR_KIND_NO_BUILTIN;
|
||||
case Attribute::NoCallback:
|
||||
return bitc::ATTR_KIND_NO_CALLBACK;
|
||||
case Attribute::NoCapture:
|
||||
return bitc::ATTR_KIND_NO_CAPTURE;
|
||||
case Attribute::NoDuplicate:
|
||||
|
@ -371,6 +371,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
|
||||
return "noalias";
|
||||
if (hasAttribute(Attribute::NoBuiltin))
|
||||
return "nobuiltin";
|
||||
if (hasAttribute(Attribute::NoCallback))
|
||||
return "nocallback";
|
||||
if (hasAttribute(Attribute::NoCapture))
|
||||
return "nocapture";
|
||||
if (hasAttribute(Attribute::NoDuplicate))
|
||||
|
@ -1597,6 +1597,7 @@ static bool isFuncOnlyAttr(Attribute::AttrKind Kind) {
|
||||
case Attribute::NoReturn:
|
||||
case Attribute::NoSync:
|
||||
case Attribute::WillReturn:
|
||||
case Attribute::NoCallback:
|
||||
case Attribute::NoCfCheck:
|
||||
case Attribute::NoUnwind:
|
||||
case Attribute::NoInline:
|
||||
|
@ -946,6 +946,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs,
|
||||
case Attribute::NoRecurse:
|
||||
case Attribute::InlineHint:
|
||||
case Attribute::MinSize:
|
||||
case Attribute::NoCallback:
|
||||
case Attribute::NoDuplicate:
|
||||
case Attribute::NoFree:
|
||||
case Attribute::NoImplicitFloat:
|
||||
|
@ -404,6 +404,12 @@ define void @f68() mustprogress
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK; define void @f69() #43
|
||||
define void @f70() nocallback
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: attributes #0 = { noreturn }
|
||||
; CHECK: attributes #1 = { nounwind }
|
||||
; CHECK: attributes #2 = { readnone }
|
||||
@ -446,4 +452,5 @@ define void @f68() mustprogress
|
||||
; CHECK: attributes #39 = { sanitize_memtag }
|
||||
; CHECK: attributes #40 = { null_pointer_is_valid }
|
||||
; CHECK: attributes #41 = { mustprogress }
|
||||
; CHECK: attributes #42 = { nocallback }
|
||||
; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
|
||||
|
Loading…
Reference in New Issue
Block a user