diff options
| author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 19:56:27 +0000 | 
|---|---|---|
| committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 19:56:27 +0000 | 
| commit | b6725054b833a2e16ca7819fc73f649826a01e47 (patch) | |
| tree | e994211363760719fcdb5d8646587af671c04a27 /llvm | |
| parent | c18d9d53bbce6a2d57e46048d484838d787581aa (diff) | |
| download | bcm5719-llvm-b6725054b833a2e16ca7819fc73f649826a01e47.tar.gz bcm5719-llvm-b6725054b833a2e16ca7819fc73f649826a01e47.zip  | |
Fix the -opt switch and add a test case for it.
llvm-svn: 51784
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/LLVMC/opt-test.c | 12 | ||||
| -rw-r--r-- | llvm/tools/llvmc2/CompilationGraph.cpp | 4 | ||||
| -rw-r--r-- | llvm/tools/llvmc2/Tools.td | 15 | ||||
| -rw-r--r-- | llvm/tools/llvmc2/llvmc.cpp | 4 | 
4 files changed, 27 insertions, 8 deletions
diff --git a/llvm/test/LLVMC/opt-test.c b/llvm/test/LLVMC/opt-test.c new file mode 100644 index 00000000000..25ca66a5c6b --- /dev/null +++ b/llvm/test/LLVMC/opt-test.c @@ -0,0 +1,12 @@ +/* + * Check that the -opt switch works. + * RUN: llvmc2 %s -opt -o %t + * RUN: ./%t | grep hello + */ + +#include <stdio.h> + +int main() { +    printf("hello\n"); +    return 0; +} diff --git a/llvm/tools/llvmc2/CompilationGraph.cpp b/llvm/tools/llvmc2/CompilationGraph.cpp index 9cdcac38457..acf391a2906 100644 --- a/llvm/tools/llvmc2/CompilationGraph.cpp +++ b/llvm/tools/llvmc2/CompilationGraph.cpp @@ -151,6 +151,10 @@ namespace {        Out.appendComponent(BaseName);      }      Out.appendSuffix(Suffix); +    // NOTE: makeUnique always *creates* a unique temporary file, +    // which is good, since there will be no races. However, some +    // tools do not like it when the output file already exists, so +    // they have to be placated with -f or something like that.      Out.makeUnique(true, NULL);      return Out;    } diff --git a/llvm/tools/llvmc2/Tools.td b/llvm/tools/llvmc2/Tools.td index 28fba8d5a36..852d7fea062 100644 --- a/llvm/tools/llvmc2/Tools.td +++ b/llvm/tools/llvmc2/Tools.td @@ -27,9 +27,12 @@ def llvm_gcc_c : Tool<   (output_suffix "bc"),   (cmd_line (case              (switch_on "E"), -              "llvm-g++ -E -x c $INFILE", +              (case (not_empty "o"), +                    "llvm-gcc -E -x c++ $INFILE -o $OUTFILE", +                    (default), +                    "llvm-gcc -E -x c++ $INFILE"),              (default), -              "llvm-g++ -c -x c $INFILE -o $OUTFILE -emit-llvm")), +              "llvm-gcc -c -x c $INFILE -o $OUTFILE -emit-llvm")),   (switch_option "E", (stop_compilation),     (help "Stop after the preprocessing stage, do not run the compiler")),   (sink) @@ -41,8 +44,10 @@ def llvm_gcc_cpp : Tool<   (output_suffix "bc"),   (cmd_line (case              (switch_on "E"), -              // TOFIX: this does not play well with -o -              "llvm-g++ -E -x c++ $INFILE", +              (case (not_empty "o"), +                    "llvm-g++ -E -x c++ $INFILE -o $OUTFILE", +                    (default), +                    "llvm-g++ -E -x c++ $INFILE"),              (default),                "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),   (switch_option "E", (stop_compilation)), @@ -54,7 +59,7 @@ def opt : Tool<   (out_language "llvm-bitcode"),   (switch_option "opt", (help "Enable opt")),   (output_suffix "bc"), - (cmd_line "opt $INFILE -o $OUTFILE") + (cmd_line "opt -f $INFILE -o $OUTFILE")  ]>;  def llvm_as : Tool< diff --git a/llvm/tools/llvmc2/llvmc.cpp b/llvm/tools/llvmc2/llvmc.cpp index 560ee98173a..e073845d09e 100644 --- a/llvm/tools/llvmc2/llvmc.cpp +++ b/llvm/tools/llvmc2/llvmc.cpp @@ -32,8 +32,6 @@ using namespace llvmc;  // Built-in command-line options.  // External linkage here is intentional. -// TOFIX: Write a 'driver driver' (easier to do as a separate -// executable that drives llvmc2 proper).  cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),                                       cl::ZeroOrMore);  cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"), @@ -42,7 +40,7 @@ cl::list<std::string> Languages("x",            cl::desc("Specify the language of the following input files"),            cl::ZeroOrMore);  cl::opt<bool> DryRun("dry-run", -                     cl::desc("only pretend to run commands")); +                     cl::desc("Only pretend to run commands"));  cl::opt<bool> VerboseMode("v",                            cl::desc("Enable verbose mode"));  cl::opt<bool> WriteGraph("write-graph",  | 

