mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[LLVM] Accept noundef
attribute in function definitions/calls
The `noundef` attribute indicates an argument or return value which may never have an undef value representation. This patch allows LLVM to parse the attribute. Differential Revision: https://reviews.llvm.org/D83412
This commit is contained in:
parent
905f645c80
commit
fd0e16a1c5
@ -643,6 +643,7 @@ enum AttributeKindCodes {
|
||||
ATTR_KIND_PREALLOCATED = 65,
|
||||
ATTR_KIND_NO_MERGE = 66,
|
||||
ATTR_KIND_NULL_POINTER_IS_VALID = 67,
|
||||
ATTR_KIND_NOUNDEF = 68,
|
||||
};
|
||||
|
||||
enum ComdatSelectionKindCodes {
|
||||
|
@ -39,6 +39,9 @@ def Builtin : EnumAttr<"builtin">;
|
||||
/// Pass structure by value.
|
||||
def ByVal : TypeAttr<"byval">;
|
||||
|
||||
/// Parameter or return value may not contain uninitialized or poison bits.
|
||||
def NoUndef : EnumAttr<"noundef">;
|
||||
|
||||
/// Marks function as being in a cold path.
|
||||
def Cold : EnumAttr<"cold">;
|
||||
|
||||
|
@ -664,6 +664,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(noreturn);
|
||||
KEYWORD(nosync);
|
||||
KEYWORD(nocf_check);
|
||||
KEYWORD(noundef);
|
||||
KEYWORD(nounwind);
|
||||
KEYWORD(null_pointer_is_valid);
|
||||
KEYWORD(optforfuzzing);
|
||||
|
@ -1374,6 +1374,7 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
|
||||
case lltok::kw_inalloca:
|
||||
case lltok::kw_nest:
|
||||
case lltok::kw_noalias:
|
||||
case lltok::kw_noundef:
|
||||
case lltok::kw_nocapture:
|
||||
case lltok::kw_nonnull:
|
||||
case lltok::kw_returned:
|
||||
@ -1677,6 +1678,9 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) {
|
||||
case lltok::kw_inalloca: B.addAttribute(Attribute::InAlloca); break;
|
||||
case lltok::kw_inreg: B.addAttribute(Attribute::InReg); break;
|
||||
case lltok::kw_nest: B.addAttribute(Attribute::Nest); break;
|
||||
case lltok::kw_noundef:
|
||||
B.addAttribute(Attribute::NoUndef);
|
||||
break;
|
||||
case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
|
||||
case lltok::kw_nocapture: B.addAttribute(Attribute::NoCapture); break;
|
||||
case lltok::kw_nofree: B.addAttribute(Attribute::NoFree); break;
|
||||
@ -1774,6 +1778,9 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) {
|
||||
}
|
||||
case lltok::kw_inreg: B.addAttribute(Attribute::InReg); break;
|
||||
case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
|
||||
case lltok::kw_noundef:
|
||||
B.addAttribute(Attribute::NoUndef);
|
||||
break;
|
||||
case lltok::kw_nonnull: B.addAttribute(Attribute::NonNull); break;
|
||||
case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
|
||||
case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
|
||||
|
@ -196,6 +196,7 @@ enum Kind {
|
||||
kw_naked,
|
||||
kw_nest,
|
||||
kw_noalias,
|
||||
kw_noundef,
|
||||
kw_nobuiltin,
|
||||
kw_nocapture,
|
||||
kw_noduplicate,
|
||||
|
@ -1530,6 +1530,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
|
||||
return Attribute::SanitizeMemTag;
|
||||
case bitc::ATTR_KIND_PREALLOCATED:
|
||||
return Attribute::Preallocated;
|
||||
case bitc::ATTR_KIND_NOUNDEF:
|
||||
return Attribute::NoUndef;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -731,6 +731,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
|
||||
return bitc::ATTR_KIND_SANITIZE_MEMTAG;
|
||||
case Attribute::Preallocated:
|
||||
return bitc::ATTR_KIND_PREALLOCATED;
|
||||
case Attribute::NoUndef:
|
||||
return bitc::ATTR_KIND_NOUNDEF;
|
||||
case Attribute::EndAttrKinds:
|
||||
llvm_unreachable("Can not encode end-attribute kinds marker.");
|
||||
case Attribute::None:
|
||||
|
@ -443,6 +443,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
|
||||
return "cold";
|
||||
if (hasAttribute(Attribute::ImmArg))
|
||||
return "immarg";
|
||||
if (hasAttribute(Attribute::NoUndef))
|
||||
return "noundef";
|
||||
|
||||
if (hasAttribute(Attribute::ByVal)) {
|
||||
std::string Result;
|
||||
|
@ -877,6 +877,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs,
|
||||
case Attribute::NoMerge:
|
||||
case Attribute::NoReturn:
|
||||
case Attribute::NoSync:
|
||||
case Attribute::NoUndef:
|
||||
case Attribute::None:
|
||||
case Attribute::NonNull:
|
||||
case Attribute::Preallocated:
|
||||
|
@ -386,6 +386,12 @@ define void @f65() null_pointer_is_valid
|
||||
ret void;
|
||||
}
|
||||
|
||||
; CHECK: define noundef i32 @f66(i32 noundef %a)
|
||||
define noundef i32 @f66(i32 noundef %a)
|
||||
{
|
||||
ret i32 %a
|
||||
}
|
||||
|
||||
; CHECK: attributes #0 = { noreturn }
|
||||
; CHECK: attributes #1 = { nounwind }
|
||||
; CHECK: attributes #2 = { readnone }
|
||||
|
Loading…
x
Reference in New Issue
Block a user