From 7c31085b1c95290c834bc3d8d25d7b3b61b90c7b Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 1 Oct 2008 23:41:25 +0000 Subject: [PATCH] Attributes noinline alwaysinline are incompatible git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56939 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Attributes.h | 5 +++-- lib/VMCore/Verifier.cpp | 17 +++++++++++++++++ test/Assembler/2008-09-02-FunctionNotes2.ll | 3 +-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index 1e54ddfc87f..d8f6cf6f095 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -60,10 +60,11 @@ const Attributes ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly; const Attributes VarArgsIncompatible = StructRet; /// @brief Attributes that are mutually incompatible. -const Attributes MutuallyIncompatible[3] = { +const Attributes MutuallyIncompatible[4] = { ByVal | InReg | Nest | StructRet, ZExt | SExt, - ReadNone | ReadOnly + ReadNone | ReadOnly, + NoInline | AlwaysInline }; /// @brief Which attributes cannot be applied to a type. diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 42d76ef4a19..527b1da87e2 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -475,6 +475,23 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT, if (Attr.Attrs & Attribute::StructRet) Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V); } + + Attributes FAttrs = Attrs.getFnAttributes(); + for (unsigned i = 0; + i < array_lengthof(Attribute::MutuallyIncompatible); ++i) { + Attributes MutI = FAttrs & Attribute::MutuallyIncompatible[i]; + Assert1(!(MutI & (MutI - 1)), "Attributes " + + Attribute::getAsString(MutI) + " are incompatible!", V); + } + + Attributes RAttrs = Attrs.getRetAttributes(); + for (unsigned i = 0; + i < array_lengthof(Attribute::MutuallyIncompatible); ++i) { + Attributes MutI = RAttrs & Attribute::MutuallyIncompatible[i]; + Assert1(!(MutI & (MutI - 1)), "Attributes " + + Attribute::getAsString(MutI) + " are incompatible!", V); + } + } static bool VerifyAttributeCount(const AttrListPtr &Attrs, unsigned Params) { diff --git a/test/Assembler/2008-09-02-FunctionNotes2.ll b/test/Assembler/2008-09-02-FunctionNotes2.ll index 966e0f87ba2..dbe75be700b 100644 --- a/test/Assembler/2008-09-02-FunctionNotes2.ll +++ b/test/Assembler/2008-09-02-FunctionNotes2.ll @@ -1,6 +1,5 @@ ; Test function notes -; RUN: not llvm-as %s -o /dev/null -f |& grep "only one inline note" -; XFAIL: * +; RUN: not llvm-as %s -o /dev/null -f |& grep "Attributes noinline alwaysinline are incompatible" define void @fn1() alwaysinline noinline { ret void } -- 2.11.0