[llvm-commits] [llvm] r98080 - /llvm/trunk/lib/MC/MCAssembler.cpp

Daniel Dunbar daniel at zuster.org
Tue Mar 9 13:27:31 PST 2010


Author: ddunbar
Date: Tue Mar  9 15:27:30 2010
New Revision: 98080

URL: http://llvm.org/viewvc/llvm-project?rev=98080&view=rev
Log:
MC/Mach-O: Don't generate relocations for PCrel fixups to local labels.

Modified:
    llvm/trunk/lib/MC/MCAssembler.cpp

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=98080&r1=98079&r2=98080&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Tue Mar  9 15:27:30 2010
@@ -440,7 +440,7 @@
                              DenseMap<const MCSymbol*,MCSymbolData*> &SymbolMap,
                                      std::vector<MachRelocationEntry> &Relocs) {
     uint32_t Address = Fragment.getOffset() + Fixup.Offset;
-    unsigned IsPCRel = 0;
+    unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
     unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
     unsigned Type = RIT_Vanilla;
 
@@ -468,10 +468,16 @@
 
     // The value which goes in the fixup is current value of the expression.
     Fixup.FixedValue = Value - Value2 + Target.getConstant();
-    if (isFixupKindPCRel(Fixup.Kind)) {
+    if (IsPCRel)
       Fixup.FixedValue -= Address;
-      IsPCRel = 1;
-    }
+
+    // If this fixup is a vanilla PC relative relocation for a local label, we
+    // don't need a relocation.
+    //
+    // FIXME: Implement proper atom support.
+    if (IsPCRel && Target.getSymA() && Target.getSymA()->isTemporary() &&
+        !Target.getSymB())
+      return;
 
     MachRelocationEntry MRE;
     MRE.Word0 = ((Address   <<  0) |
@@ -516,7 +522,7 @@
     uint32_t Address = Fragment.getOffset() + Fixup.Offset;
     uint32_t Value = 0;
     unsigned Index = 0;
-    unsigned IsPCRel = 0;
+    unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
     unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
     unsigned IsExtern = 0;
     unsigned Type = 0;
@@ -554,11 +560,15 @@
 
     // The value which goes in the fixup is current value of the expression.
     Fixup.FixedValue = Value + Target.getConstant();
-
-    if (isFixupKindPCRel(Fixup.Kind)) {
+    if (IsPCRel)
       Fixup.FixedValue -= Address;
-      IsPCRel = 1;
-    }
+
+    // If this fixup is a vanilla PC relative relocation for a local label, we
+    // don't need a relocation.
+    //
+    // FIXME: Implement proper atom support.
+    if (IsPCRel && Target.getSymA() && Target.getSymA()->isTemporary())
+      return;
 
     // struct relocation_info (8 bytes)
     MachRelocationEntry MRE;





More information about the llvm-commits mailing list