In order for parameter attribute uniquing to make

any sense it is important that ParamAttr::None gets
treated the same as not supplying an attribute at
all.  Rather than stripping ParamAttr::None out of
the list of attributes, assert if ParamAttr::None
is seen.  Fix up the bitcode reader which liked to
insert ParamAttr::None all over the place.  Patch
based on one by Török Edwin.

llvm-svn: 44250
This commit is contained in:
Duncan Sands 2007-11-20 14:09:29 +00:00
parent 74a26e3750
commit 04eb67e69a
2 changed files with 10 additions and 8 deletions

View File

@ -232,17 +232,15 @@ bool BitcodeReader::ParseParamAttrBlock() {
if (Record.size() & 1) if (Record.size() & 1)
return Error("Invalid ENTRY record"); return Error("Invalid ENTRY record");
ParamAttrsWithIndex PAWI;
for (unsigned i = 0, e = Record.size(); i != e; i += 2) { for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
PAWI.index = Record[i]; if (Record[i+1] != ParamAttr::None)
PAWI.attrs = Record[i+1]; Attrs.push_back(ParamAttrsWithIndex::get(Record[i], Record[i+1]));
Attrs.push_back(PAWI);
} }
ParamAttrs.push_back(ParamAttrsList::get(Attrs)); ParamAttrs.push_back(Attrs.empty() ? NULL : ParamAttrsList::get(Attrs));
Attrs.clear(); Attrs.clear();
break; break;
} }
} }
} }
} }

View File

@ -129,8 +129,12 @@ ParamAttrsList *
ParamAttrsList::get(const ParamAttrsVector &attrVec) { ParamAttrsList::get(const ParamAttrsVector &attrVec) {
assert(!attrVec.empty() && "Illegal to create empty ParamAttrsList"); assert(!attrVec.empty() && "Illegal to create empty ParamAttrsList");
#ifndef NDEBUG #ifndef NDEBUG
for (unsigned i = 1, e = attrVec.size(); i < e; ++i) for (unsigned i = 0, e = attrVec.size(); i < e; ++i) {
assert(attrVec[i-1].index < attrVec[i].index && "Misordered ParamAttrsList!"); assert(attrVec[i].attrs != ParamAttr::None
&& "Pointless parameter attribute!");
assert((!i || attrVec[i-1].index < attrVec[i].index)
&& "Misordered ParamAttrsList!");
}
#endif #endif
ParamAttrsList key(attrVec); ParamAttrsList key(attrVec);
FoldingSetNodeID ID; FoldingSetNodeID ID;