namespace llvm {
+class MCSectionXCOFF;
+
class MCSymbolXCOFF : public MCSymbol {
public:
MCSymbolXCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
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
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");
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);