Simplify a really complicated check for Arch == X86_64.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 11 Mar 2014 21:22:57 +0000 (21:22 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 11 Mar 2014 21:22:57 +0000 (21:22 +0000)
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

include/llvm/MC/MCAsmBackend.h
include/llvm/MC/MCAssembler.h
include/llvm/MC/MCMachObjectWriter.h
lib/MC/MCAsmBackend.cpp
lib/MC/MachObjectWriter.cpp
lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

index 9d46b22b8d5cdd70a3c5e5dae3111efcafaa1e93..0e96af872de2c8668215d209df8d866b519489c2 100644 (file)
@@ -38,7 +38,6 @@ class MCAsmBackend {
 protected: // Can only create subclasses.
   MCAsmBackend();
 
-  unsigned HasReliableSymbolDifference : 1;
   unsigned HasDataInCodeSupport : 1;
 
 public:
@@ -58,20 +57,6 @@ public:
                      "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
   /// markers. If not, data region directives will be ignored.
   bool hasDataInCodeSupport() const { return HasDataInCodeSupport; }
index da236a548a69350bd24be3093c77d61a413d411f..c4b475ee03c584d7da1f3aff478248b6a66a5d1f 100644 (file)
@@ -66,8 +66,7 @@ private:
   MCSectionData *Parent;
 
   /// Atom - The atom this fragment is in, as represented by it's defining
-  /// symbol. Atom's are only used by backends which set
-  /// \see MCAsmBackend::hasReliableSymbolDifference().
+  /// symbol.
   MCSymbolData *Atom;
 
   /// @name Assembler Backend Data
index 5d868cff8483878010aac96f3d0513b06ea94be3..644b44eceebf3b361c55e4ce9f5a352370b7e43c 100644 (file)
@@ -153,6 +153,10 @@ public:
   /// @{
 
   bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
+  bool isX86_64() const {
+    uint32_t CPUType = TargetObjectWriter->getCPUType();
+    return CPUType == MachO::CPU_TYPE_X86_64;
+  }
 
   /// @}
 
index c4c98cc900acafccca98459792d8da6909e44fa3..c42757b70c8ba9f09fe6b188bcc964397201251f 100644 (file)
@@ -12,8 +12,7 @@
 #include "llvm/MC/MCFixupKindInfo.h"
 using namespace llvm;
 
-MCAsmBackend::MCAsmBackend()
-  : HasReliableSymbolDifference(false), HasDataInCodeSupport(false) {}
+MCAsmBackend::MCAsmBackend() : HasDataInCodeSupport(false) {}
 
 MCAsmBackend::~MCAsmBackend() {}
 
index 00347f546fc8eaf1f93983051ce2b0a105751d62..edbd2b98b28c46f71dcd76cb7bcf08230ca571fa 100644 (file)
@@ -688,7 +688,8 @@ IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
     // same assumptions about any symbol that we normally make about
     // assembler locals.
 
-    if (!Asm.getBackend().hasReliableSymbolDifference()) {
+    bool hasReliableSymbolDifference = isX86_64();
+    if (!hasReliableSymbolDifference) {
       if (!SA.isInSection() || &SecA != &SecB ||
           (!SA.isTemporary() &&
            FB.getAtom() != Asm.getSymbolData(SA).getFragment()->getAtom() &&
index 8830e643fd95bfe487a1b3a273aa87c9916531fe..3063ec61373410320be2223a0e26af91be5a1b9b 100644 (file)
@@ -739,7 +739,6 @@ public:
                          MachO::CPUSubTypeX86 st)
     : DarwinX86AsmBackend(T, MRI, CPU, true), SupportsCU(SupportsCU),
       Subtype(st) {
-    HasReliableSymbolDifference = true;
   }
 
   MCObjectWriter *createObjectWriter(raw_ostream &OS) const override {