[Attr] Add "willreturn" function attribute

This patch introduces a new function attribute, willreturn, to indicate
that a call of this function will either exhibit undefined behavior or
comes back and continues execution at a point in the existing call stack
that includes the current invocation.

This attribute guarantees that the function does not have any endless
loops, endless recursion, or terminating functions like abort or exit.

Patch by Hideto Ueno (@uenoku)

Reviewers: jdoerfert

Subscribers: mehdi_amini, hiraditya, steven_wu, dexonsmith, lebedev.ri, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62801

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364555 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Johannes Doerfert
2019-06-27 15:51:40 +00:00
parent 068d4d9024
commit 8a0fc5ba4f
13 changed files with 503 additions and 3 deletions

View File

@@ -1272,6 +1272,8 @@ static uint64_t getRawAttributeMask(Attribute::AttrKind Val) {
return 1ULL << 60;
case Attribute::ImmArg:
return 1ULL << 61;
case Attribute::WillReturn:
return 1ULL << 62;
case Attribute::Dereferenceable:
llvm_unreachable("dereferenceable attribute not supported in raw format");
break;
@@ -1510,6 +1512,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::SwiftSelf;
case bitc::ATTR_KIND_UW_TABLE:
return Attribute::UWTable;
case bitc::ATTR_KIND_WILLRETURN:
return Attribute::WillReturn;
case bitc::ATTR_KIND_WRITEONLY:
return Attribute::WriteOnly;
case bitc::ATTR_KIND_Z_EXT: