aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2013-07-06 00:29:58 +0000
committerNick Lewycky <nicholas@mxc.ca>2013-07-06 00:29:58 +0000
commitdc89737bcdbb8f69d8ae7578bdfa904cabcfc5ed (patch)
tree1838b5d8368383a083fad1cdca2fe777528e5a69 /lib/IR/Verifier.cpp
parent202eb7b18e220205ec86a03ddf18f2066c70ab15 (diff)
downloadexternal_llvm-dc89737bcdbb8f69d8ae7578bdfa904cabcfc5ed.zip
external_llvm-dc89737bcdbb8f69d8ae7578bdfa904cabcfc5ed.tar.gz
external_llvm-dc89737bcdbb8f69d8ae7578bdfa904cabcfc5ed.tar.bz2
Extend 'readonly' and 'readnone' to work on function arguments as well as
functions. Make the function attributes pass add it to known library functions and when it can deduce it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Verifier.cpp')
-rw-r--r--lib/IR/Verifier.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 8b4c165..420bc15 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -654,7 +654,7 @@ void Verifier::visitModuleFlag(MDNode *Op, DenseMap<MDString*, MDNode*>&SeenIDs,
}
void Verifier::VerifyAttributeTypes(AttributeSet Attrs, unsigned Idx,
- bool isFunction, const Value* V) {
+ bool isFunction, const Value *V) {
unsigned Slot = ~0U;
for (unsigned I = 0, E = Attrs.getNumSlots(); I != E; ++I)
if (Attrs.getSlotIndex(I) == Idx) {
@@ -671,8 +671,6 @@ void Verifier::VerifyAttributeTypes(AttributeSet Attrs, unsigned Idx,
if (I->getKindAsEnum() == Attribute::NoReturn ||
I->getKindAsEnum() == Attribute::NoUnwind ||
- I->getKindAsEnum() == Attribute::ReadNone ||
- I->getKindAsEnum() == Attribute::ReadOnly ||
I->getKindAsEnum() == Attribute::NoInline ||
I->getKindAsEnum() == Attribute::AlwaysInline ||
I->getKindAsEnum() == Attribute::OptimizeForSize ||
@@ -696,14 +694,21 @@ void Verifier::VerifyAttributeTypes(AttributeSet Attrs, unsigned Idx,
I->getKindAsEnum() == Attribute::NoBuiltin ||
I->getKindAsEnum() == Attribute::Cold) {
if (!isFunction) {
- CheckFailed("Attribute '" + I->getAsString() +
- "' only applies to functions!", V);
- return;
+ CheckFailed("Attribute '" + I->getAsString() +
+ "' only applies to functions!", V);
+ return;
}
- } else if (isFunction) {
+ } else if (I->getKindAsEnum() == Attribute::ReadOnly ||
+ I->getKindAsEnum() == Attribute::ReadNone) {
+ if (Idx == 0) {
CheckFailed("Attribute '" + I->getAsString() +
- "' does not apply to functions!", V);
+ "' does not apply to function returns");
return;
+ }
+ } else if (isFunction) {
+ CheckFailed("Attribute '" + I->getAsString() +
+ "' does not apply to functions!", V);
+ return;
}
}
}