[llvm-commits] [llvm] r51784 - in /llvm/trunk: test/LLVMC/opt-test.c tools/llvmc2/CompilationGraph.cpp tools/llvmc2/Tools.td tools/llvmc2/llvmc.cpp
Mikhail Glushenkov
foldr at codedgers.com
Fri May 30 12:56:27 PDT 2008
Author: foldr
Date: Fri May 30 14:56:27 2008
New Revision: 51784
URL: http://llvm.org/viewvc/llvm-project?rev=51784&view=rev
Log:
Fix the -opt switch and add a test case for it.
Added:
llvm/trunk/test/LLVMC/opt-test.c
Modified:
llvm/trunk/tools/llvmc2/CompilationGraph.cpp
llvm/trunk/tools/llvmc2/Tools.td
llvm/trunk/tools/llvmc2/llvmc.cpp
Added: llvm/trunk/test/LLVMC/opt-test.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/opt-test.c?rev=51784&view=auto
==============================================================================
--- llvm/trunk/test/LLVMC/opt-test.c (added)
+++ llvm/trunk/test/LLVMC/opt-test.c Fri May 30 14:56:27 2008
@@ -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;
+}
Modified: llvm/trunk/tools/llvmc2/CompilationGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.cpp?rev=51784&r1=51783&r2=51784&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/CompilationGraph.cpp (original)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.cpp Fri May 30 14:56:27 2008
@@ -151,6 +151,10 @@
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;
}
Modified: llvm/trunk/tools/llvmc2/Tools.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tools.td?rev=51784&r1=51783&r2=51784&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.td (original)
+++ llvm/trunk/tools/llvmc2/Tools.td Fri May 30 14:56:27 2008
@@ -27,9 +27,12 @@
(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 @@
(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 @@
(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<
Modified: llvm/trunk/tools/llvmc2/llvmc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/llvmc.cpp?rev=51784&r1=51783&r2=51784&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/llvmc.cpp (original)
+++ llvm/trunk/tools/llvmc2/llvmc.cpp Fri May 30 14:56:27 2008
@@ -32,8 +32,6 @@
// 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::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",
More information about the llvm-commits
mailing list