Simplify a really complicated check for Arch == X86_64.

The function hasReliableSymbolDifference had exactly one use in the MachO
writer. It is also only true for X86_64. In fact, the comments refers to
"Darwin x86_64" and everything else, so this makes the code match the
comment.

If this is to be abstracted again, it should be a property of
TargetObjectWriter, like useAggressiveSymbolFolding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203605 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-03-11 21:22:57 +00:00
parent 819af77aa3
commit d1742f6136
6 changed files with 8 additions and 21 deletions

View File

@ -38,7 +38,6 @@ class MCAsmBackend {
protected: // Can only create subclasses. protected: // Can only create subclasses.
MCAsmBackend(); MCAsmBackend();
unsigned HasReliableSymbolDifference : 1;
unsigned HasDataInCodeSupport : 1; unsigned HasDataInCodeSupport : 1;
public: public:
@ -58,20 +57,6 @@ public:
"backend"); "backend");
} }
/// hasReliableSymbolDifference - Check whether this target implements
/// accurate relocations for differences between symbols. If not, differences
/// between symbols will always be relocatable expressions and any references
/// to temporary symbols will be assumed to be in the same atom, unless they
/// reside in a different section.
///
/// This should always be true (since it results in fewer relocations with no
/// loss of functionality), but is currently supported as a way to maintain
/// exact object compatibility with Darwin 'as' (on non-x86_64). It should
/// eventually should be eliminated.
bool hasReliableSymbolDifference() const {
return HasReliableSymbolDifference;
}
/// hasDataInCodeSupport - Check whether this target implements data-in-code /// hasDataInCodeSupport - Check whether this target implements data-in-code
/// markers. If not, data region directives will be ignored. /// markers. If not, data region directives will be ignored.
bool hasDataInCodeSupport() const { return HasDataInCodeSupport; } bool hasDataInCodeSupport() const { return HasDataInCodeSupport; }

View File

@ -66,8 +66,7 @@ private:
MCSectionData *Parent; MCSectionData *Parent;
/// Atom - The atom this fragment is in, as represented by it's defining /// Atom - The atom this fragment is in, as represented by it's defining
/// symbol. Atom's are only used by backends which set /// symbol.
/// \see MCAsmBackend::hasReliableSymbolDifference().
MCSymbolData *Atom; MCSymbolData *Atom;
/// @name Assembler Backend Data /// @name Assembler Backend Data

View File

@ -153,6 +153,10 @@ public:
/// @{ /// @{
bool is64Bit() const { return TargetObjectWriter->is64Bit(); } bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
bool isX86_64() const {
uint32_t CPUType = TargetObjectWriter->getCPUType();
return CPUType == MachO::CPU_TYPE_X86_64;
}
/// @} /// @}

View File

@ -12,8 +12,7 @@
#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCFixupKindInfo.h"
using namespace llvm; using namespace llvm;
MCAsmBackend::MCAsmBackend() MCAsmBackend::MCAsmBackend() : HasDataInCodeSupport(false) {}
: HasReliableSymbolDifference(false), HasDataInCodeSupport(false) {}
MCAsmBackend::~MCAsmBackend() {} MCAsmBackend::~MCAsmBackend() {}

View File

@ -688,7 +688,8 @@ IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
// same assumptions about any symbol that we normally make about // same assumptions about any symbol that we normally make about
// assembler locals. // assembler locals.
if (!Asm.getBackend().hasReliableSymbolDifference()) { bool hasReliableSymbolDifference = isX86_64();
if (!hasReliableSymbolDifference) {
if (!SA.isInSection() || &SecA != &SecB || if (!SA.isInSection() || &SecA != &SecB ||
(!SA.isTemporary() && (!SA.isTemporary() &&
FB.getAtom() != Asm.getSymbolData(SA).getFragment()->getAtom() && FB.getAtom() != Asm.getSymbolData(SA).getFragment()->getAtom() &&

View File

@ -739,7 +739,6 @@ public:
MachO::CPUSubTypeX86 st) MachO::CPUSubTypeX86 st)
: DarwinX86AsmBackend(T, MRI, CPU, true), SupportsCU(SupportsCU), : DarwinX86AsmBackend(T, MRI, CPU, true), SupportsCU(SupportsCU),
Subtype(st) { Subtype(st) {
HasReliableSymbolDifference = true;
} }
MCObjectWriter *createObjectWriter(raw_ostream &OS) const override { MCObjectWriter *createObjectWriter(raw_ostream &OS) const override {