diff options
author | Daniel Dunbar <daniel@zuster.org> | 2013-01-16 21:38:56 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2013-01-16 21:38:56 +0000 |
commit | d77d9fb04d8973b9493cb7c30d2e4b6c8f8292ed (patch) | |
tree | ce2a61295fcc044c6094cfa16a33142c275f3e9e /llvm/lib/IR | |
parent | f104c4c4ca8f561078497f36127cdf0fdc54cb88 (diff) | |
download | bcm5719-llvm-d77d9fb04d8973b9493cb7c30d2e4b6c8f8292ed.tar.gz bcm5719-llvm-d77d9fb04d8973b9493cb7c30d2e4b6c8f8292ed.zip |
[IR] Add 'Append' and 'AppendUnique' module flag behaviors.
llvm-svn: 172659
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 2488a7de169..49821f24f23 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -571,24 +571,25 @@ void Verifier::visitModuleFlag(MDNode *Op, DenseMap<MDString*, MDNode*>&SeenIDs, "invalid behavior operand in module flag (expected constant integer)", Op->getOperand(0)); unsigned BehaviorValue = Behavior->getZExtValue(); - Assert1((Module::Error <= BehaviorValue && - BehaviorValue <= Module::Override), - "invalid behavior operand in module flag (unexpected constant)", - Op->getOperand(0)); Assert1(ID, "invalid ID operand in module flag (expected metadata string)", Op->getOperand(1)); - // Unless this is a "requires" flag, check the ID is unique. - if (BehaviorValue != Module::Require) { - bool Inserted = SeenIDs.insert(std::make_pair(ID, Op)).second; - Assert1(Inserted, - "module flag identifiers must be unique (or of 'require' type)", - ID); - } + // Sanity check the values for behaviors with additional requirements. + switch (BehaviorValue) { + default: + Assert1(false, + "invalid behavior operand in module flag (unexpected constant)", + Op->getOperand(0)); + break; - // If this is a "requires" flag, sanity check the value. - if (BehaviorValue == Module::Require) { + case Module::Error: + case Module::Warning: + case Module::Override: + // These behavior types accept any value. + break; + + case Module::Require: { // The value should itself be an MDNode with two operands, a flag ID (an // MDString), and a value. MDNode *Value = dyn_cast<MDNode>(Op->getOperand(2)); @@ -603,6 +604,25 @@ void Verifier::visitModuleFlag(MDNode *Op, DenseMap<MDString*, MDNode*>&SeenIDs, // Append it to the list of requirements, to check once all module flags are // scanned. Requirements.push_back(Value); + break; + } + + case Module::Append: + case Module::AppendUnique: { + // These behavior types require the operand be an MDNode. + Assert1(isa<MDNode>(Op->getOperand(2)), + "invalid value for 'append'-type module flag " + "(expected a metadata node)", Op->getOperand(2)); + break; + } + } + + // Unless this is a "requires" flag, check the ID is unique. + if (BehaviorValue != Module::Require) { + bool Inserted = SeenIDs.insert(std::make_pair(ID, Op)).second; + Assert1(Inserted, + "module flag identifiers must be unique (or of 'require' type)", + ID); } } |