mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
make the autoupgrade code for ret attributes dramatically simpler
and actually work. We can now read the llvm 2.3 bc file from PR2849 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57122 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -355,10 +355,10 @@ bool BitcodeReader::ParseAttributeBlock() {
|
|||||||
if (Record.size() & 1)
|
if (Record.size() & 1)
|
||||||
return Error("Invalid ENTRY record");
|
return Error("Invalid ENTRY record");
|
||||||
|
|
||||||
// FIXME : Remove this backword compatibility one day.
|
// FIXME : Remove this autoupgrade code in LLVM 3.0.
|
||||||
// If Function attributes are using index 0 then transfer them
|
// If Function attributes are using index 0 then transfer them
|
||||||
// to index ~0. Index 0 is strictly used for return value
|
// to index ~0. Index 0 is used for return value attributes but used to be
|
||||||
// attributes.
|
// used for function attributes.
|
||||||
Attributes RetAttribute = Attribute::None;
|
Attributes RetAttribute = Attribute::None;
|
||||||
Attributes FnAttribute = Attribute::None;
|
Attributes FnAttribute = Attribute::None;
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
@@ -367,39 +367,31 @@ bool BitcodeReader::ParseAttributeBlock() {
|
|||||||
else if (Record[i] == ~0U)
|
else if (Record[i] == ~0U)
|
||||||
FnAttribute = Record[i+1];
|
FnAttribute = Record[i+1];
|
||||||
}
|
}
|
||||||
bool useUpdatedAttrs = false;
|
|
||||||
if (FnAttribute == Attribute::None && RetAttribute != Attribute::None) {
|
unsigned OldRetAttrs = (Attribute::NoUnwind|Attribute::NoReturn|
|
||||||
if (RetAttribute & Attribute::NoUnwind) {
|
Attribute::ReadOnly|Attribute::ReadNone);
|
||||||
FnAttribute = FnAttribute | Attribute::NoUnwind;
|
|
||||||
RetAttribute = RetAttribute ^ Attribute::NoUnwind;
|
if (FnAttribute == Attribute::None && RetAttribute != Attribute::None &&
|
||||||
useUpdatedAttrs = true;
|
(RetAttribute & OldRetAttrs) != 0) {
|
||||||
}
|
if (FnAttribute == Attribute::None) { // add a slot so they get added.
|
||||||
if (RetAttribute & Attribute::NoReturn) {
|
Record.push_back(~0U);
|
||||||
FnAttribute = FnAttribute | Attribute::NoReturn;
|
Record.push_back(0);
|
||||||
RetAttribute = RetAttribute ^ Attribute::NoReturn;
|
|
||||||
useUpdatedAttrs = true;
|
|
||||||
}
|
|
||||||
if (RetAttribute & Attribute::ReadOnly) {
|
|
||||||
FnAttribute = FnAttribute | Attribute::ReadOnly;
|
|
||||||
RetAttribute = RetAttribute ^ Attribute::ReadOnly;
|
|
||||||
useUpdatedAttrs = true;
|
|
||||||
}
|
|
||||||
if (RetAttribute & Attribute::ReadNone) {
|
|
||||||
FnAttribute = FnAttribute | Attribute::ReadNone;
|
|
||||||
RetAttribute = RetAttribute ^ Attribute::ReadNone;
|
|
||||||
useUpdatedAttrs = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FnAttribute |= RetAttribute & OldRetAttrs;
|
||||||
|
RetAttribute &= ~OldRetAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
if (useUpdatedAttrs && Record[i] == 0
|
if (Record[i] == 0) {
|
||||||
&& RetAttribute != Attribute::None)
|
if (RetAttribute != Attribute::None)
|
||||||
Attrs.push_back(AttributeWithIndex::get(0, RetAttribute));
|
Attrs.push_back(AttributeWithIndex::get(0, RetAttribute));
|
||||||
else if (Record[i+1] != Attribute::None)
|
} else if (Record[i] == ~0U) {
|
||||||
|
if (FnAttribute != Attribute::None)
|
||||||
|
Attrs.push_back(AttributeWithIndex::get(~0U, FnAttribute));
|
||||||
|
} else if (Record[i+1] != Attribute::None)
|
||||||
Attrs.push_back(AttributeWithIndex::get(Record[i], Record[i+1]));
|
Attrs.push_back(AttributeWithIndex::get(Record[i], Record[i+1]));
|
||||||
}
|
}
|
||||||
if (useUpdatedAttrs && FnAttribute != Attribute::None)
|
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0, FnAttribute));
|
|
||||||
|
|
||||||
MAttributes.push_back(AttrListPtr::get(Attrs.begin(), Attrs.end()));
|
MAttributes.push_back(AttrListPtr::get(Attrs.begin(), Attrs.end()));
|
||||||
Attrs.clear();
|
Attrs.clear();
|
||||||
|
Reference in New Issue
Block a user