mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Fix resetting the DataLayout in a Module.
No tool does this currently, but as everything else in a module we should be able to change its DataLayout. Most of the fix is in DataLayout to make sure it can be reset properly. The test uses Module::setDataLayout since the fact that we mutate a DataLayout is an implementation detail. The module could hold a OwningPtr<DataLayout> and the DataLayout itself could be immutable. Thanks to Philip Reames for pushing me in the right direction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -176,7 +176,9 @@ static const LayoutAlignElem DefaultAlignments[] = {
|
||||
{ AGGREGATE_ALIGN, 0, 0, 8 } // struct
|
||||
};
|
||||
|
||||
void DataLayout::init(StringRef Desc) {
|
||||
void DataLayout::reset(StringRef Desc) {
|
||||
clear();
|
||||
|
||||
LayoutMap = 0;
|
||||
LittleEndian = false;
|
||||
StackNaturalAlign = 0;
|
||||
@ -344,12 +346,12 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
}
|
||||
}
|
||||
|
||||
DataLayout::DataLayout(const Module *M) {
|
||||
DataLayout::DataLayout(const Module *M) : LayoutMap(0) {
|
||||
const DataLayout *Other = M->getDataLayout();
|
||||
if (Other)
|
||||
*this = *Other;
|
||||
else
|
||||
init("");
|
||||
reset("");
|
||||
}
|
||||
|
||||
void
|
||||
@ -469,8 +471,16 @@ public:
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
void DataLayout::clear() {
|
||||
LegalIntWidths.clear();
|
||||
Alignments.clear();
|
||||
Pointers.clear();
|
||||
delete static_cast<StructLayoutMap *>(LayoutMap);
|
||||
LayoutMap = 0;
|
||||
}
|
||||
|
||||
DataLayout::~DataLayout() {
|
||||
delete static_cast<StructLayoutMap*>(LayoutMap);
|
||||
clear();
|
||||
}
|
||||
|
||||
const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
|
||||
|
Reference in New Issue
Block a user