mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[PowerPC][XCOFF][MC] Explicitly set containing csect on symbols. [NFC]
Previously we would get the csect a symbol was contained in through its fragment. This works only if we are writing an object file, and only for defined symbols. To fix this we set the contating csect explicitly on the MCSymbolXCOFF object. Differential Revision: https://reviews.llvm.org/D66032 llvm-svn: 369657
This commit is contained in:
parent
ee40acc2c2
commit
b71112d703
@ -14,6 +14,8 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MCSectionXCOFF;
|
||||
|
||||
class MCSymbolXCOFF : public MCSymbol {
|
||||
public:
|
||||
MCSymbolXCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
|
||||
@ -33,8 +35,22 @@ public:
|
||||
return StorageClass.getValue();
|
||||
}
|
||||
|
||||
void setContainingCsect(const MCSectionXCOFF *C) {
|
||||
assert((!ContainingCsect || ContainingCsect == C) &&
|
||||
"Trying to set a containing csect that doesn't match the one that"
|
||||
"this symbol is already mapped to.");
|
||||
ContainingCsect = C;
|
||||
}
|
||||
|
||||
const MCSectionXCOFF *getContainingCsect() const {
|
||||
assert(ContainingCsect &&
|
||||
"Trying to get containing csect but none was set.");
|
||||
return ContainingCsect;
|
||||
}
|
||||
|
||||
private:
|
||||
Optional<XCOFF::StorageClass> StorageClass;
|
||||
const MCSectionXCOFF *ContainingCsect = nullptr;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -247,8 +247,7 @@ void XCOFFObjectWriter::executePostLayoutBinding(
|
||||
const MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(&S);
|
||||
|
||||
// Map the symbol into its containing csect.
|
||||
MCSectionXCOFF *ContainingCsect =
|
||||
dyn_cast<MCSectionXCOFF>(XSym->getFragment(false)->getParent());
|
||||
const MCSectionXCOFF *ContainingCsect = XSym->getContainingCsect();
|
||||
assert(WrapperMap.find(ContainingCsect) != WrapperMap.end() &&
|
||||
"Expected containing csect to exist in map");
|
||||
|
||||
|
@ -1671,6 +1671,8 @@ void PPCAIXAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(getSymbol(GV));
|
||||
XSym->setStorageClass(
|
||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GV));
|
||||
XSym->setContainingCsect(CSect);
|
||||
|
||||
const DataLayout &DL = GV->getParent()->getDataLayout();
|
||||
unsigned Align =
|
||||
GV->getAlignment() ? GV->getAlignment() : DL.getPreferredAlignment(GV);
|
||||
|
Loading…
x
Reference in New Issue
Block a user