[llvm] r267075 - MachO: enable .data_region directives everywhere

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 16:00:17 PDT 2016


Author: tnorthover
Date: Thu Apr 21 18:00:17 2016
New Revision: 267075

URL: http://llvm.org/viewvc/llvm-project?rev=267075&view=rev
Log:
MachO: enable .data_region directives everywhere

We'd disabled them on x86 because back in the early days some host tools
couldn't handle the new load commands. This no longer holds: anyone capable of
deploying Clang should be able to deploy its copies of ar/ranlib/etc.

rdar://25254790

Added:
    llvm/trunk/test/MC/MachO/AArch64/data-in-code.s
    llvm/trunk/test/MC/MachO/x86-data-in-code.s
Removed:
    llvm/trunk/test/MC/MachO/x86-data-in-code.ll
Modified:
    llvm/trunk/include/llvm/MC/MCAsmBackend.h
    llvm/trunk/lib/MC/MCAsmBackend.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp
    llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h

Modified: llvm/trunk/include/llvm/MC/MCAsmBackend.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmBackend.h?rev=267075&r1=267074&r2=267075&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmBackend.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmBackend.h Thu Apr 21 18:00:17 2016
@@ -39,8 +39,6 @@ class MCAsmBackend {
 protected: // Can only create subclasses.
   MCAsmBackend();
 
-  unsigned HasDataInCodeSupport : 1;
-
 public:
   virtual ~MCAsmBackend();
 
@@ -58,10 +56,6 @@ public:
                      "backend");
   }
 
-  /// Check whether this target implements data-in-code markers. If not, data
-  /// region directives will be ignored.
-  bool hasDataInCodeSupport() const { return HasDataInCodeSupport; }
-
   /// \name Target Fixup Interfaces
   /// @{
 

Modified: llvm/trunk/lib/MC/MCAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmBackend.cpp?rev=267075&r1=267074&r2=267075&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmBackend.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmBackend.cpp Thu Apr 21 18:00:17 2016
@@ -12,7 +12,7 @@
 #include "llvm/MC/MCFixupKindInfo.h"
 using namespace llvm;
 
-MCAsmBackend::MCAsmBackend() : HasDataInCodeSupport(false) {}
+MCAsmBackend::MCAsmBackend() {}
 
 MCAsmBackend::~MCAsmBackend() {}
 

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=267075&r1=267074&r2=267075&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Apr 21 18:00:17 2016
@@ -214,8 +214,6 @@ void MCMachOStreamer::EmitAssignment(MCS
 }
 
 void MCMachOStreamer::EmitDataRegion(DataRegionData::KindTy Kind) {
-  if (!getAssembler().getBackend().hasDataInCodeSupport())
-    return;
   // Create a temporary label to mark the start of the data region.
   MCSymbol *Start = getContext().createTempSymbol();
   EmitLabel(Start);
@@ -226,8 +224,6 @@ void MCMachOStreamer::EmitDataRegion(Dat
 }
 
 void MCMachOStreamer::EmitDataRegionEnd() {
-  if (!getAssembler().getBackend().hasDataInCodeSupport())
-    return;
   std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
   assert(!Regions.empty() && "Mismatched .end_data_region!");
   DataRegionData &Data = Regions.back();

Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h?rev=267075&r1=267074&r2=267075&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h Thu Apr 21 18:00:17 2016
@@ -21,7 +21,6 @@ public:
   ARMAsmBackendDarwin(const Target &T, const Triple &TT,
                       const MCRegisterInfo &MRI, MachO::CPUSubTypeARM st)
       : ARMAsmBackend(T, TT, /* IsLittleEndian */ true), MRI(MRI), Subtype(st) {
-    HasDataInCodeSupport = true;
   }
 
   MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {

Added: llvm/trunk/test/MC/MachO/AArch64/data-in-code.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/AArch64/data-in-code.s?rev=267075&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/AArch64/data-in-code.s (added)
+++ llvm/trunk/test/MC/MachO/AArch64/data-in-code.s Thu Apr 21 18:00:17 2016
@@ -0,0 +1,49 @@
+// RUN: llvm-mc -triple arm64-apple-darwin10 -filetype=obj -o - < %s | llvm-readobj --macho-data-in-code | FileCheck %s
+        .text
+_foo:
+.data_region
+        .long 10
+.end_data_region
+.data_region jt32
+        .long 1
+.end_data_region
+.data_region jt16
+        .short 2
+.end_data_region
+.data_region jt8
+        .byte 3
+.end_data_region
+
+// CHECK: File: <stdin>
+// CHECK: Format: Mach-O arm64
+// CHECK: Arch: aarch64
+// CHECK: AddressSize: 64bit
+// CHECK: DataInCode {
+// CHECK:   Data size: 32
+// CHECK:   Data entries [
+// CHECK:     Entry {
+// CHECK:       Index: 0
+// CHECK:       Offset: 0
+// CHECK:       Length: 4
+// CHECK:       Kind: 1
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 1
+// CHECK:       Offset: 4
+// CHECK:       Length: 4
+// CHECK:       Kind: 4
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 2
+// CHECK:       Offset: 8
+// CHECK:       Length: 2
+// CHECK:       Kind: 3
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 3
+// CHECK:       Offset: 10
+// CHECK:       Length: 1
+// CHECK:       Kind: 2
+// CHECK:     }
+// CHECK:   ]
+// CHECK: }

Removed: llvm/trunk/test/MC/MachO/x86-data-in-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/x86-data-in-code.ll?rev=267074&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/x86-data-in-code.ll (original)
+++ llvm/trunk/test/MC/MachO/x86-data-in-code.ll (removed)
@@ -1,107 +0,0 @@
-; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-readobj -macho-data-in-code | FileCheck %s
-
-; There should not be a data-in-code load command (type 0x29) for x86_64
-; jump tables, even though they are in the text section.
-; CHECK-NOT: DataInCode {
-
-define void @foo(i32* %ptr) nounwind ssp {
-  %tmp = load i32, i32* %ptr, align 4
-  switch i32 %tmp, label %default [
-    i32 11, label %bb0
-    i32 10, label %bb1
-    i32 8, label %bb2
-    i32 4, label %bb3
-    i32 2, label %bb4
-    i32 6, label %bb5
-    i32 9, label %bb6
-    i32 15, label %bb7
-    i32 1, label %bb8
-    i32 3, label %bb9
-    i32 5, label %bb10
-    i32 30, label %bb11
-    i32 31, label %bb12
-    i32 13, label %bb13
-    i32 14, label %bb14
-    i32 20, label %bb15
-    i32 19, label %bb16
-    i32 17, label %bb17
-    i32 18, label %bb18
-    i32 21, label %bb19
-    i32 22, label %bb20
-    i32 16, label %bb21
-    i32 24, label %bb22
-    i32 25, label %bb23
-    i32 26, label %bb24
-    i32 27, label %bb25
-    i32 28, label %bb26
-    i32 23, label %bb27
-    i32 12, label %bb28
-  ]
-
-default:
-  br label %exit
-bb0:
-  br label %exit
-bb1:
-  br label %exit
-bb2:
-  br label %exit
-bb3:
-  br label %exit
-bb4:
-  br label %exit
-bb5:
-  br label %exit
-bb6:
-  br label %exit
-bb7:
-  br label %exit
-bb8:
-  br label %exit
-bb9:
-  br label %exit
-bb10:
-  br label %exit
-bb11:
-  br label %exit
-bb12:
-  br label %exit
-bb13:
-  br label %exit
-bb14:
-  br label %exit
-bb15:
-  br label %exit
-bb16:
-  br label %exit
-bb17:
-  br label %exit
-bb18:
-  br label %exit
-bb19:
-  br label %exit
-bb20:
-  br label %exit
-bb21:
-  br label %exit
-bb22:
-  br label %exit
-bb23:
-  br label %exit
-bb24:
-  br label %exit
-bb25:
-  br label %exit
-bb26:
-  br label %exit
-bb27:
-  br label %exit
-bb28:
-  br label %exit
-
-
-exit:
-
-  ret void
-}
-

Added: llvm/trunk/test/MC/MachO/x86-data-in-code.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/x86-data-in-code.s?rev=267075&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/x86-data-in-code.s (added)
+++ llvm/trunk/test/MC/MachO/x86-data-in-code.s Thu Apr 21 18:00:17 2016
@@ -0,0 +1,47 @@
+// RUN: llvm-mc -triple x86_64-apple-darwin10 -filetype=obj -o - < %s | llvm-readobj --macho-data-in-code | FileCheck %s
+// RUN: llvm-mc -triple i686-apple-darwin10 -filetype=obj -o - < %s | llvm-readobj --macho-data-in-code | FileCheck %s
+
+        .text
+_foo:
+.data_region
+        .long 10
+.end_data_region
+.data_region jt32
+        .long 1
+.end_data_region
+.data_region jt16
+        .short 2
+.end_data_region
+.data_region jt8
+        .byte 3
+.end_data_region
+
+// CHECK: DataInCode {
+// CHECK:   Data size: 32
+// CHECK:   Data entries [
+// CHECK:     Entry {
+// CHECK:       Index: 0
+// CHECK:       Offset: 0
+// CHECK:       Length: 4
+// CHECK:       Kind: 1
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 1
+// CHECK:       Offset: 4
+// CHECK:       Length: 4
+// CHECK:       Kind: 4
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 2
+// CHECK:       Offset: 8
+// CHECK:       Length: 2
+// CHECK:       Kind: 3
+// CHECK:     }
+// CHECK:     Entry {
+// CHECK:       Index: 3
+// CHECK:       Offset: 10
+// CHECK:       Length: 1
+// CHECK:       Kind: 2
+// CHECK:     }
+// CHECK:   ]
+// CHECK: }




More information about the llvm-commits mailing list