mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Revert r240762 "[X86] Cleanup X86WindowsTargetObjectFile::getSectionForConstant"
It seems to have caused PR23966: "UNREACHABLE executed at ..\lib\Target\X86\X86TargetObjectFile.cpp:148" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240793 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
438a4919fd
commit
57ec696dfd
@ -131,40 +131,52 @@ static std::string APIntToHexString(const APInt &AI) {
|
|||||||
return HexString;
|
return HexString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::string scalarConstantToHexString(const Constant *C) {
|
static std::string scalarConstantToHexString(const Constant *C) {
|
||||||
Type *Ty = C->getType();
|
Type *Ty = C->getType();
|
||||||
|
APInt AI;
|
||||||
if (isa<UndefValue>(C)) {
|
if (isa<UndefValue>(C)) {
|
||||||
return APIntToHexString(APInt::getNullValue(Ty->getPrimitiveSizeInBits()));
|
AI = APInt(Ty->getPrimitiveSizeInBits(), /*val=*/0);
|
||||||
} else if (const auto *CFP = dyn_cast<ConstantFP>(C)) {
|
} else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
|
||||||
return APIntToHexString(CFP->getValueAPF().bitcastToAPInt());
|
const auto *CFP = cast<ConstantFP>(C);
|
||||||
} else if (const auto *CI = dyn_cast<ConstantInt>(C)) {
|
AI = CFP->getValueAPF().bitcastToAPInt();
|
||||||
return APIntToHexString(CI->getValue());
|
} else if (Ty->isIntegerTy()) {
|
||||||
} else if (const auto *VTy = dyn_cast<VectorType>(Ty)) {
|
const auto *CI = cast<ConstantInt>(C);
|
||||||
std::string HexString;
|
AI = CI->getValue();
|
||||||
for (int I = VTy->getNumElements() - 1, E = -1; I != E; --I)
|
} else {
|
||||||
HexString += scalarConstantToHexString(C->getAggregateElement(I));
|
llvm_unreachable("unexpected constant pool element type!");
|
||||||
return HexString;
|
|
||||||
}
|
}
|
||||||
llvm_unreachable("unexpected constant pool element type!");
|
return APIntToHexString(AI);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
MCSection *
|
||||||
X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
||||||
const Constant *C) const {
|
const Constant *C) const {
|
||||||
if (Kind.isMergeableConst() && C) {
|
if (Kind.isReadOnly()) {
|
||||||
const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
if (C) {
|
||||||
COFF::IMAGE_SCN_MEM_READ |
|
Type *Ty = C->getType();
|
||||||
COFF::IMAGE_SCN_LNK_COMDAT;
|
SmallString<32> COMDATSymName;
|
||||||
std::string COMDATSymName;
|
if (Ty->isFloatTy() || Ty->isDoubleTy()) {
|
||||||
if (Kind.isMergeableConst4() || Kind.isMergeableConst8())
|
COMDATSymName = "__real@";
|
||||||
COMDATSymName = "__real@" + scalarConstantToHexString(C);
|
COMDATSymName += scalarConstantToHexString(C);
|
||||||
else if (Kind.isMergeableConst16())
|
} else if (const auto *VTy = dyn_cast<VectorType>(Ty)) {
|
||||||
COMDATSymName = "__xmm@" + scalarConstantToHexString(C);
|
uint64_t NumBits = VTy->getBitWidth();
|
||||||
|
if (NumBits == 128 || NumBits == 256) {
|
||||||
if (!COMDATSymName.empty())
|
COMDATSymName = NumBits == 128 ? "__xmm@" : "__ymm@";
|
||||||
return getContext().getCOFFSection(".rdata", Characteristics, Kind,
|
for (int I = VTy->getNumElements() - 1, E = -1; I != E; --I)
|
||||||
COMDATSymName,
|
COMDATSymName +=
|
||||||
COFF::IMAGE_COMDAT_SELECT_ANY);
|
scalarConstantToHexString(C->getAggregateElement(I));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!COMDATSymName.empty()) {
|
||||||
|
unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||||
|
COFF::IMAGE_SCN_MEM_READ |
|
||||||
|
COFF::IMAGE_SCN_LNK_COMDAT;
|
||||||
|
return getContext().getCOFFSection(".rdata", Characteristics, Kind,
|
||||||
|
COMDATSymName,
|
||||||
|
COFF::IMAGE_COMDAT_SELECT_ANY);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TargetLoweringObjectFile::getSectionForConstant(Kind, C);
|
return TargetLoweringObjectFile::getSectionForConstant(Kind, C);
|
||||||
|
Loading…
Reference in New Issue
Block a user