forked from OSchip/llvm-project
Add -fno-jump-tables and-fjump-tables flags
Add no-jump-tables flag to disable use of jump tables when lowering switch statements Reviewers: echristo, hans Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18407 llvm-svn: 265425
This commit is contained in:
parent
376ab7cc7b
commit
d2f44d8de0
|
@ -586,6 +586,9 @@ def fno_math_errno : Flag<["-"], "fno-math-errno">, Group<f_Group>;
|
|||
def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group<f_Group>;
|
||||
def fsignaling_math : Flag<["-"], "fsignaling-math">, Group<f_Group>;
|
||||
def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group<f_Group>;
|
||||
def fjump_tables : Flag<["-"], "fjump-tables">, Group<f_Group>;
|
||||
def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group<f_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Do not use jump tables for lowering switches">;
|
||||
def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group<f_clang_Group>,
|
||||
Flags<[CC1Option, CoreOption]>, MetaVarName<"<check>">,
|
||||
HelpText<"Turn on runtime checks for various forms of undefined "
|
||||
|
|
|
@ -149,6 +149,7 @@ CODEGENOPT(UnitAtATime , 1, 1) ///< Unused. For mirroring GCC optimization
|
|||
///< selection.
|
||||
CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled.
|
||||
CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled.
|
||||
CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled
|
||||
CODEGENOPT(UnsafeFPMath , 1, 0) ///< Allow unsafe floating point optzns.
|
||||
CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables.
|
||||
CODEGENOPT(VectorizeBB , 1, 0) ///< Run basic block vectorizer.
|
||||
|
|
|
@ -711,6 +711,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
|
|||
Fn->addFnAttr(llvm::Attribute::NoInline);
|
||||
}
|
||||
|
||||
// Add no-jump-tables value.
|
||||
Fn->addFnAttr("no-jump-tables",
|
||||
llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
|
||||
|
||||
if (getLangOpts().OpenCL) {
|
||||
// Add metadata for a kernel function.
|
||||
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
|
||||
|
|
|
@ -3891,6 +3891,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
A->claim();
|
||||
}
|
||||
|
||||
if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
|
||||
true))
|
||||
CmdArgs.push_back("-fno-jump-tables");
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
|
||||
CmdArgs.push_back("-mregparm");
|
||||
CmdArgs.push_back(A->getValue());
|
||||
|
|
|
@ -606,6 +606,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
|
||||
Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
|
||||
|
||||
Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
|
||||
|
||||
Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
|
||||
const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
|
||||
Opts.EmitSummaryIndex = A && A->containsValue("thin");
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// RUN: %clang_cc1 -S -fno-jump-tables %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
// CHECK-LABEL: main
|
||||
// CHECK: attributes #0 = {{.*}}"no-jump-tables"="true"{{.*}}
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue