aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-09-23 22:35:17 +0000
committerDevang Patel <dpatel@apple.com>2008-09-23 22:35:17 +0000
commitd9b4a5f859188cbb168c223071b413e58c53c925 (patch)
tree04fec821fbc9cdc4f37ab86adc1dcfeb3243d644 /lib/VMCore/Verifier.cpp
parentb2c3e3fdd9987fc2d08eb8f7892db2cbc7ec74d9 (diff)
downloadexternal_llvm-d9b4a5f859188cbb168c223071b413e58c53c925.zip
external_llvm-d9b4a5f859188cbb168c223071b413e58c53c925.tar.gz
external_llvm-d9b4a5f859188cbb168c223071b413e58c53c925.tar.bz2
Use parameter attribute store (soon to be renamed) for
Function Notes also. Function notes are stored at index ~0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index be053ab..f4a59c2 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -477,6 +477,19 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
}
}
+static bool VerifyAttributeCount(const PAListPtr &Attrs, unsigned Params) {
+ if (Attrs.isEmpty())
+ return true;
+
+ unsigned LastSlot = Attrs.getNumSlots() - 1;
+ unsigned LastIndex = Attrs.getSlot(LastSlot).Index;
+ if (LastIndex <= Params
+ || (LastIndex == (unsigned)~0
+ && (LastSlot == 0 || Attrs.getSlot(LastSlot - 1).Index <= Params)))
+ return true;
+
+ return false;
+}
// visitFunction - Verify that a function is ok.
//
void Verifier::visitFunction(Function &F) {
@@ -497,8 +510,7 @@ void Verifier::visitFunction(Function &F) {
const PAListPtr &Attrs = F.getParamAttrs();
- Assert1(Attrs.isEmpty() ||
- Attrs.getSlot(Attrs.getNumSlots()-1).Index <= FT->getNumParams(),
+ Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()),
"Attributes after last parameter!", &F);
// Check function attributes.
@@ -955,8 +967,7 @@ void Verifier::VerifyCallSite(CallSite CS) {
const PAListPtr &Attrs = CS.getParamAttrs();
- Assert1(Attrs.isEmpty() ||
- Attrs.getSlot(Attrs.getNumSlots()-1).Index <= CS.arg_size(),
+ Assert1(VerifyAttributeCount(Attrs, CS.arg_size()),
"Attributes after last parameter!", I);
// Verify call attributes.