[patch] Start fixing pr24429
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 06:18:06 PDT 2015
On 11 August 2015 at 22:52, David Majnemer <david.majnemer at gmail.com> wrote:
> I'm afraid I don't see a patch, could you please re-attach one?
Really sorry. Attached.
Cheers,
Rafael
-------------- next part --------------
diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h
index b9cea06..5711897 100644
--- a/include/llvm/MC/MCObjectFileInfo.h
+++ b/include/llvm/MC/MCObjectFileInfo.h
@@ -331,13 +331,9 @@ public:
return EHFrameSection;
}
- enum Environment { IsMachO, IsELF, IsCOFF };
- Environment getObjectFileType() const { return Env; }
-
Reloc::Model getRelocM() const { return RelocM; }
private:
- Environment Env;
Reloc::Model RelocM;
CodeModel::Model CMModel;
MCContext *Ctx;
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index c601c56..e8fb6a9 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -162,13 +162,15 @@ MCSymbol *MCContext::getOrCreateLSDASymbol(StringRef FuncName) {
MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
bool IsTemporary) {
if (MOFI) {
- switch (MOFI->getObjectFileType()) {
- case MCObjectFileInfo::IsCOFF:
+ switch (MOFI->getTargetTriple().getObjectFormat()) {
+ case Triple::COFF:
return new (Name, *this) MCSymbolCOFF(Name, IsTemporary);
- case MCObjectFileInfo::IsELF:
+ case Triple::ELF:
return new (Name, *this) MCSymbolELF(Name, IsTemporary);
- case MCObjectFileInfo::IsMachO:
+ case Triple::MachO:
return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
+ case Triple::UnknownObjectFormat:
+ break;
}
}
return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp
index 576827a..ade4b49 100644
--- a/lib/MC/MCObjectFileInfo.cpp
+++ b/lib/MC/MCObjectFileInfo.cpp
@@ -767,25 +767,19 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple,
TT = TheTriple;
- Triple::ArchType Arch = TT.getArch();
- // FIXME: Checking for Arch here to filter out bogus triples such as
- // cellspu-apple-darwin. Perhaps we should fix in Triple?
- if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb ||
- Arch == Triple::aarch64 ||
- Arch == Triple::ppc || Arch == Triple::ppc64 ||
- Arch == Triple::UnknownArch) &&
- TT.isOSBinFormatMachO()) {
- Env = IsMachO;
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
initMachOMCObjectFileInfo(TT);
- } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb) &&
- (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
- Env = IsCOFF;
+ break;
+ case Triple::COFF:
initCOFFMCObjectFileInfo(TT);
- } else {
- Env = IsELF;
+ break;
+ case Triple::ELF:
initELFMCObjectFileInfo(TT);
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
}
}
@@ -801,7 +795,9 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
}
void MCObjectFileInfo::InitEHFrameSection() {
- if (Env == IsMachO)
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
EHFrameSection =
Ctx->getMachOSection("__TEXT", "__eh_frame",
MachO::S_COALESCED |
@@ -809,14 +805,20 @@ void MCObjectFileInfo::InitEHFrameSection() {
MachO::S_ATTR_STRIP_STATIC_SYMS |
MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnly());
- else if (Env == IsELF)
+ break;
+ case Triple::ELF:
EHFrameSection =
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- else
+ break;
+ case Triple::COFF:
EHFrameSection =
Ctx->getCOFFSection(".eh_frame",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE,
SectionKind::getDataRel());
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
+ }
}
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index 3f45b3d..0089f8f 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -513,17 +513,19 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
// Initialize the platform / file format parser.
- switch (Ctx.getObjectFileInfo()->getObjectFileType()) {
- case MCObjectFileInfo::IsCOFF:
+ switch (Ctx.getObjectFileInfo()->getTargetTriple().getObjectFormat()) {
+ case Triple::COFF:
PlatformParser.reset(createCOFFAsmParser());
break;
- case MCObjectFileInfo::IsMachO:
+ case Triple::MachO:
PlatformParser.reset(createDarwinAsmParser());
IsDarwin = true;
break;
- case MCObjectFileInfo::IsELF:
+ case Triple::ELF:
PlatformParser.reset(createELFAsmParser());
break;
+ case Triple::UnknownObjectFormat:
+ break;
}
PlatformParser->Initialize(*this);
diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 44ed4de..22877d7 100644
--- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -4045,10 +4045,10 @@ bool AArch64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
/// ParseDirective parses the arm specific directives
bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) {
- const MCObjectFileInfo::Environment Format =
- getContext().getObjectFileInfo()->getObjectFileType();
- bool IsMachO = Format == MCObjectFileInfo::IsMachO;
- bool IsCOFF = Format == MCObjectFileInfo::IsCOFF;
+ Triple::ObjectFormatType Format =
+ getContext().getObjectFileInfo()->getTargetTriple().getObjectFormat();
+ bool IsMachO = Format == Triple::MachO;
+ bool IsCOFF = Format == Triple::COFF;
StringRef IDVal = DirectiveID.getIdentifier();
SMLoc Loc = DirectiveID.getLoc();
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 2d291bf..21414b0 100644
--- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -5173,18 +5173,11 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
return true;
}
- enum {
- COFF = (1 << MCObjectFileInfo::IsCOFF),
- ELF = (1 << MCObjectFileInfo::IsELF),
- MACHO = (1 << MCObjectFileInfo::IsMachO)
- };
static const struct PrefixEntry {
const char *Spelling;
ARMMCExpr::VariantKind VariantKind;
- uint8_t SupportedFormats;
} PrefixEntries[] = {
- { "lower16", ARMMCExpr::VK_ARM_LO16, COFF | ELF | MACHO },
- { "upper16", ARMMCExpr::VK_ARM_HI16, COFF | ELF | MACHO },
+ {"lower16", ARMMCExpr::VK_ARM_LO16}, {"upper16", ARMMCExpr::VK_ARM_HI16},
};
StringRef IDVal = Parser.getTok().getIdentifier();
@@ -5199,25 +5192,6 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
return true;
}
- uint8_t CurrentFormat;
- switch (getContext().getObjectFileInfo()->getObjectFileType()) {
- case MCObjectFileInfo::IsMachO:
- CurrentFormat = MACHO;
- break;
- case MCObjectFileInfo::IsELF:
- CurrentFormat = ELF;
- break;
- case MCObjectFileInfo::IsCOFF:
- CurrentFormat = COFF;
- break;
- }
-
- if (~Prefix->SupportedFormats & CurrentFormat) {
- Error(Parser.getTok().getLoc(),
- "cannot represent relocation in the current file format");
- return true;
- }
-
RefKind = Prefix->VariantKind;
Parser.Lex();
@@ -8691,10 +8665,10 @@ bool ARMAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
/// parseDirective parses the arm specific directives
bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
- const MCObjectFileInfo::Environment Format =
- getContext().getObjectFileInfo()->getObjectFileType();
- bool IsMachO = Format == MCObjectFileInfo::IsMachO;
- bool IsCOFF = Format == MCObjectFileInfo::IsCOFF;
+ Triple::ObjectFormatType Format =
+ getContext().getObjectFileInfo()->getTargetTriple().getObjectFormat();
+ bool IsMachO = Format == Triple::MachO;
+ bool IsCOFF = Format == Triple::COFF;
StringRef IDVal = DirectiveID.getIdentifier();
if (IDVal == ".word")
@@ -8859,8 +8833,9 @@ void ARMAsmParser::onLabelParsed(MCSymbol *Symbol) {
/// ::= .thumbfunc symbol_name
bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
MCAsmParser &Parser = getParser();
- const auto Format = getContext().getObjectFileInfo()->getObjectFileType();
- bool IsMachO = Format == MCObjectFileInfo::IsMachO;
+ Triple::ObjectFormatType Format =
+ getContext().getObjectFileInfo()->getTargetTriple().getObjectFormat();
+ bool IsMachO = Format == Triple::MachO;
// Darwin asm has (optionally) function name after .thumb_func direction
// ELF doesn't
diff --git a/test/CodeGen/X86/statepoint-stackmap-format.ll b/test/CodeGen/X86/statepoint-stackmap-format.ll
index e18476c..2b7f077 100644
--- a/test/CodeGen/X86/statepoint-stackmap-format.ll
+++ b/test/CodeGen/X86/statepoint-stackmap-format.ll
@@ -1,5 +1,5 @@
; RUN: llc < %s -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
-; RUN: llc < %s -mtriple="x86_64-pc-win64-coff" | FileCheck %s
+; RUN: llc < %s -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
; This test is a sanity check to ensure statepoints are generating StackMap
; sections correctly. This is not intended to be a rigorous test of the
diff --git a/test/MC/COFF/ARM/directive-type-diagnostics.s b/test/MC/COFF/ARM/directive-type-diagnostics.s
deleted file mode 100644
index f8a52cd..0000000
--- a/test/MC/COFF/ARM/directive-type-diagnostics.s
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: not llvm-mc -triple arm-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
-// RUN: not llvm-mc -triple armeb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
-// RUN: not llvm-mc -triple thumb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
-// RUN: not llvm-mc -triple thumbeb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
-
- .type symbol 32
-// CHECK: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>"
-// CHECK: .type symbol 32
-// CHECK: ^
-
More information about the llvm-commits
mailing list