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.

llvm-svn: 209238
This commit is contained in:
Eric Christopher 2014-05-20 21:25:34 +00:00
parent 64976a2a23
commit 2feed5fd68
6 changed files with 69 additions and 61 deletions

View File

@ -193,6 +193,15 @@ cl::opt<std::string> StartAfter("start-after",
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 InitTargetOptionsFromCodeGenFlags() {
Options.TrapFuncName = TrapFuncName;
Options.PositionIndependentExecutable = EnablePIE;
Options.UseInitArray = UseInitArray;
Options.DataSections = DataSections;
Options.FunctionSections = FunctionSections;
Options.MCOptions = InitMCTargetOptionsFromFlags();

View File

@ -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 &) {}

View File

@ -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;

View File

@ -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::setAsmVerbosityDefault(bool V) {
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,

View File

@ -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

View File

@ -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