[llvm] r209238 - Move the function and data section flags into the options struct and
Eric Christopher
echristo at gmail.com
Tue May 20 14:25:34 PDT 2014
Author: echristo
Date: Tue May 20 16:25:34 2014
New Revision: 209238
URL: http://llvm.org/viewvc/llvm-project?rev=209238&view=rev
Log:
Move the function and data section flags into the options struct and
make the functions to set them non-static.
Move and rename the llvm specific backend options to avoid conflicting
with the clang option.
Paired with a backend commit to update.
Modified:
llvm/trunk/include/llvm/CodeGen/CommandFlags.h
llvm/trunk/include/llvm/Target/TargetMachine.h
llvm/trunk/include/llvm/Target/TargetOptions.h
llvm/trunk/lib/Target/TargetMachine.cpp
llvm/trunk/test/CodeGen/X86/global-sections.ll
llvm/trunk/test/DebugInfo/X86/cu-ranges.ll
Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
+++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Tue May 20 16:25:34 2014
@@ -193,6 +193,15 @@ cl::opt<std::string> StartAfter("start-a
cl::value_desc("pass-name"),
cl::init(""));
+cl::opt<bool> DataSections("data-sections",
+ cl::desc("Emit data into separate sections"),
+ cl::init(false));
+
+cl::opt<bool>
+FunctionSections("function-sections",
+ cl::desc("Emit functions into separate sections"),
+ cl::init(false));
+
// Common utility function tightly tied to the options listed here. Initializes
// a TargetOptions object with CodeGen flags and returns it.
static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
@@ -215,6 +224,8 @@ static inline TargetOptions InitTargetOp
Options.TrapFuncName = TrapFuncName;
Options.PositionIndependentExecutable = EnablePIE;
Options.UseInitArray = UseInitArray;
+ Options.DataSections = DataSections;
+ Options.FunctionSections = FunctionSections;
Options.MCOptions = InitMCTargetOptionsFromFlags();
Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Tue May 20 16:25:34 2014
@@ -195,18 +195,18 @@ public:
/// getDataSections - Return true if data objects should be emitted into their
/// own section, corresponds to -fdata-sections.
- static bool getDataSections();
+ bool getDataSections() const;
/// getFunctionSections - Return true if functions should be emitted into
/// their own section, corresponding to -ffunction-sections.
- static bool getFunctionSections();
+ bool getFunctionSections() const;
/// setDataSections - Set if the data are emit into separate sections.
- static void setDataSections(bool);
+ void setDataSections(bool);
/// setFunctionSections - Set if the functions are emit into separate
/// sections.
- static void setFunctionSections(bool);
+ void setFunctionSections(bool);
/// \brief Register analysis passes for this target with a pass manager.
virtual void addAnalysisPasses(PassManagerBase &) {}
Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
+++ llvm/trunk/include/llvm/Target/TargetOptions.h Tue May 20 16:25:34 2014
@@ -50,10 +50,10 @@ namespace llvm {
JITEmitDebugInfoToDisk(false), GuaranteedTailCallOpt(false),
DisableTailCalls(false), StackAlignmentOverride(0),
EnableFastISel(false), PositionIndependentExecutable(false),
- UseInitArray(false),
- DisableIntegratedAS(false), CompressDebugSections(false),
- TrapUnreachable(false),
- TrapFuncName(""), FloatABIType(FloatABI::Default),
+ UseInitArray(false), DisableIntegratedAS(false),
+ CompressDebugSections(false), FunctionSections(false),
+ DataSections(false), TrapUnreachable(false), TrapFuncName(""),
+ FloatABIType(FloatABI::Default),
AllowFPOpFusion(FPOpFusion::Standard) {}
/// PrintMachineCode - This flag is enabled when the -print-machineinstrs
@@ -164,6 +164,12 @@ namespace llvm {
/// Compress DWARF debug sections.
unsigned CompressDebugSections : 1;
+ /// Emit functions into separate sections.
+ unsigned FunctionSections : 1;
+
+ /// Emit data into separate sections.
+ unsigned DataSections : 1;
+
/// Emit target-specific trap instruction for 'unreachable' IR instructions.
unsigned TrapUnreachable : 1;
Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Tue May 20 16:25:34 2014
@@ -36,15 +36,6 @@ namespace llvm {
bool AsmVerbosityDefault(false);
}
-static cl::opt<bool>
-DataSections("fdata-sections",
- cl::desc("Emit data into separate sections"),
- cl::init(false));
-static cl::opt<bool>
-FunctionSections("ffunction-sections",
- cl::desc("Emit functions into separate sections"),
- cl::init(false));
-
//---------------------------------------------------------------------------
// TargetMachine Class
//
@@ -179,20 +170,20 @@ void TargetMachine::setAsmVerbosityDefau
AsmVerbosityDefault = V;
}
-bool TargetMachine::getFunctionSections() {
- return FunctionSections;
+bool TargetMachine::getFunctionSections() const {
+ return Options.FunctionSections;
}
-bool TargetMachine::getDataSections() {
- return DataSections;
+bool TargetMachine::getDataSections() const {
+ return Options.DataSections;
}
void TargetMachine::setFunctionSections(bool V) {
- FunctionSections = V;
+ Options.FunctionSections = V;
}
void TargetMachine::setDataSections(bool V) {
- DataSections = V;
+ Options.DataSections = V;
}
void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name,
Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-sections.ll Tue May 20 16:25:34 2014
@@ -2,8 +2,8 @@
; RUN: llc < %s -mtriple=i386-apple-darwin9.7 | FileCheck %s -check-prefix=DARWIN
; RUN: llc < %s -mtriple=i386-apple-darwin10 -relocation-model=static | FileCheck %s -check-prefix=DARWIN-STATIC
; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s -check-prefix=DARWIN64
-; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -fdata-sections | FileCheck %s -check-prefix=LINUX-SECTIONS
-; RUN: llc < %s -mtriple=i686-pc-win32 -fdata-sections -ffunction-sections | FileCheck %s -check-prefix=WIN32-SECTIONS
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -data-sections | FileCheck %s -check-prefix=LINUX-SECTIONS
+; RUN: llc < %s -mtriple=i686-pc-win32 -data-sections -function-sections | FileCheck %s -check-prefix=WIN32-SECTIONS
define void @F1() {
ret void
@@ -18,13 +18,13 @@ define void @F1() {
; LINUX: .type G1, at object
; LINUX: .comm G1,4,4
-; DARWIN: .comm _G1,4,2
+; DARWIN: .comm _G1,4,2
; const int G2 __attribute__((weak)) = 42;
- at G2 = weak_odr unnamed_addr constant i32 42
+ at G2 = weak_odr unnamed_addr constant i32 42
; TODO: linux drops this into .rodata, we drop it into ".gnu.linkonce.r.G2"
@@ -85,25 +85,25 @@ define void @F1() {
; PR4584
@"foo bar" = linkonce global i32 42
-; LINUX: .type "foo bar", at object
+; LINUX: .type "foo bar", at object
; LINUX: .section ".data.foo bar","aGw", at progbits,"foo bar",comdat
-; LINUX: .weak "foo bar"
+; LINUX: .weak "foo bar"
; LINUX: "foo bar":
-; DARWIN: .section __DATA,__datacoal_nt,coalesced
-; DARWIN: .globl "_foo bar"
-; DARWIN: .weak_definition "_foo bar"
+; DARWIN: .section __DATA,__datacoal_nt,coalesced
+; DARWIN: .globl "_foo bar"
+; DARWIN: .weak_definition "_foo bar"
; DARWIN: "_foo bar":
; PR4650
@G6 = weak_odr unnamed_addr constant [1 x i8] c"\01"
-; LINUX: .type G6, at object
-; LINUX: .section .rodata.G6,"aG", at progbits,G6,comdat
-; LINUX: .weak G6
+; LINUX: .type G6, at object
+; LINUX: .section .rodata.G6,"aG", at progbits,G6,comdat
+; LINUX: .weak G6
; LINUX: G6:
-; LINUX: .byte 1
-; LINUX: .size G6, 1
+; LINUX: .byte 1
+; LINUX: .size G6, 1
; DARWIN: .section __TEXT,__const_coal,coalesced
; DARWIN: .globl _G6
@@ -114,58 +114,58 @@ define void @F1() {
@G7 = unnamed_addr constant [10 x i8] c"abcdefghi\00"
-; DARWIN: __TEXT,__cstring,cstring_literals
-; DARWIN: .globl _G7
+; DARWIN: __TEXT,__cstring,cstring_literals
+; DARWIN: .globl _G7
; DARWIN: _G7:
-; DARWIN: .asciz "abcdefghi"
+; DARWIN: .asciz "abcdefghi"
-; LINUX: .section .rodata.str1.1,"aMS", at progbits,1
-; LINUX: .globl G7
+; LINUX: .section .rodata.str1.1,"aMS", at progbits,1
+; LINUX: .globl G7
; LINUX: G7:
-; LINUX: .asciz "abcdefghi"
+; LINUX: .asciz "abcdefghi"
; LINUX-SECTIONS: .section .rodata.G7,"aMS", at progbits,1
-; LINUX-SECTIONS: .globl G7
+; LINUX-SECTIONS: .globl G7
; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G7
-; WIN32-SECTIONS: .globl _G7
+; WIN32-SECTIONS: .globl _G7
@G8 = unnamed_addr constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ]
-; DARWIN: .section __TEXT,__const
-; DARWIN: .globl _G8
+; DARWIN: .section __TEXT,__const
+; DARWIN: .globl _G8
; DARWIN: _G8:
-; LINUX: .section .rodata.str2.2,"aMS", at progbits,2
-; LINUX: .globl G8
+; LINUX: .section .rodata.str2.2,"aMS", at progbits,2
+; LINUX: .globl G8
; LINUX:G8:
@G9 = unnamed_addr constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ]
-; DARWIN: .globl _G9
+; DARWIN: .globl _G9
; DARWIN: _G9:
-; LINUX: .section .rodata.str4.4,"aMS", at progbits,4
-; LINUX: .globl G9
+; LINUX: .section .rodata.str4.4,"aMS", at progbits,4
+; LINUX: .globl G9
; LINUX:G9
@G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=0]
-; DARWIN: .section __DATA,__datacoal_nt,coalesced
+; DARWIN: .section __DATA,__datacoal_nt,coalesced
; DARWIN: .globl _G10
-; DARWIN: .weak_definition _G10
-; DARWIN: .align 5
+; DARWIN: .weak_definition _G10
+; DARWIN: .align 5
; DARWIN: _G10:
-; DARWIN: .space 400
+; DARWIN: .space 400
-; LINUX: .bss
-; LINUX: .weak G10
-; LINUX: .align 32
+; LINUX: .bss
+; LINUX: .weak G10
+; LINUX: .align 32
; LINUX: G10:
-; LINUX: .zero 400
+; LINUX: .zero 400
Modified: llvm/trunk/test/DebugInfo/X86/cu-ranges.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/cu-ranges.ll?rev=209238&r1=209237&r2=209238&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/cu-ranges.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/cu-ranges.ll Tue May 20 16:25:34 2014
@@ -1,4 +1,4 @@
-; RUN: llc -split-dwarf=Enable -O0 %s -ffunction-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
+; RUN: llc -split-dwarf=Enable -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s
; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s
More information about the llvm-commits
mailing list