sgundapa updated this revision to Diff 107317.
sgundapa added a comment.

Made the changes asked by reviewers


https://reviews.llvm.org/D35577

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/nouselookuptable.c


Index: test/CodeGen/nouselookuptable.c
===================================================================
--- /dev/null
+++ test/CodeGen/nouselookuptable.c
@@ -0,0 +1,14 @@
+// RUN: %clang -S -fno-lookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=NOLOOKUP %s
+// NOLOOKUP: @foo
+// NOLOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="true"{{.*}}
+
+// RUN: %clang -S %s -emit-llvm -o - | FileCheck --check-prefix=LOOKUP %s
+// RUN: %clang -S -flookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=LOOKUP %s
+// LOOKUP: @foo
+// LOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="false"{{.*}}
+
+void foo() {
+  return;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.NoUseLookupTables = Args.hasArg(OPT_fno_lookup_tables);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2266,6 +2266,10 @@
                     true))
     CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_flookup_tables, 
options::OPT_fno_lookup_tables,
+                    true))
+    CmdArgs.push_back("-fno-lookup-tables");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
                     options::OPT_fno_preserve_as_comments, true))
     CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -806,6 +806,10 @@
   Fn->addFnAttr("no-jump-tables",
                 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add no-lookup-tables value.
+  Fn->addFnAttr("no-lookup-tables",
+                llvm::toStringRef(CGM.getCodeGenOpts().NoUseLookupTables));
+
   if (getLangOpts().OpenCL) {
     // Add metadata for a kernel function.
     if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Index: include/clang/Frontend/CodeGenOptions.def
===================================================================
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -177,6 +177,7 @@
 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(NoUseLookupTables , 1, 0) ///< Set when -fno-lookup-tables is 
enabled.
 CODEGENOPT(UnsafeFPMath      , 1, 0) ///< Allow unsafe floating point optzns.
 CODEGENOPT(UnwindTables      , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop     , 1, 0) ///< Run loop vectorizer.
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -792,6 +792,9 @@
 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 flookup_tables : Flag<["-"], "flookup-tables">, Group<f_Group>;
+def fno_lookup_tables : Flag<["-"], "fno-lookup-tables">, Group<f_Group>, 
Flags<[CC1Option]>,
+  HelpText<"Do not use lookup tables for lowering switches">;
 
 // Begin sanitizer flags. These should all be core options exposed in all 
driver
 // modes.


Index: test/CodeGen/nouselookuptable.c
===================================================================
--- /dev/null
+++ test/CodeGen/nouselookuptable.c
@@ -0,0 +1,14 @@
+// RUN: %clang -S -fno-lookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=NOLOOKUP %s
+// NOLOOKUP: @foo
+// NOLOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="true"{{.*}}
+
+// RUN: %clang -S %s -emit-llvm -o - | FileCheck --check-prefix=LOOKUP %s
+// RUN: %clang -S -flookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=LOOKUP %s
+// LOOKUP: @foo
+// LOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="false"{{.*}}
+
+void foo() {
+  return;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.NoUseLookupTables = Args.hasArg(OPT_fno_lookup_tables);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2266,6 +2266,10 @@
                     true))
     CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_flookup_tables, options::OPT_fno_lookup_tables,
+                    true))
+    CmdArgs.push_back("-fno-lookup-tables");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
                     options::OPT_fno_preserve_as_comments, true))
     CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -806,6 +806,10 @@
   Fn->addFnAttr("no-jump-tables",
                 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add no-lookup-tables value.
+  Fn->addFnAttr("no-lookup-tables",
+                llvm::toStringRef(CGM.getCodeGenOpts().NoUseLookupTables));
+
   if (getLangOpts().OpenCL) {
     // Add metadata for a kernel function.
     if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Index: include/clang/Frontend/CodeGenOptions.def
===================================================================
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -177,6 +177,7 @@
 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(NoUseLookupTables , 1, 0) ///< Set when -fno-lookup-tables is enabled.
 CODEGENOPT(UnsafeFPMath      , 1, 0) ///< Allow unsafe floating point optzns.
 CODEGENOPT(UnwindTables      , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop     , 1, 0) ///< Run loop vectorizer.
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -792,6 +792,9 @@
 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 flookup_tables : Flag<["-"], "flookup-tables">, Group<f_Group>;
+def fno_lookup_tables : Flag<["-"], "fno-lookup-tables">, Group<f_Group>, Flags<[CC1Option]>,
+  HelpText<"Do not use lookup tables for lowering switches">;
 
 // Begin sanitizer flags. These should all be core options exposed in all driver
 // modes.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to