summaryrefslogtreecommitdiff
path: root/Driver
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-26 22:39:37 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-26 22:39:37 +0000
commite8e260039346695beaa15af3e64ba38a64a1c30b (patch)
treea5b7147a98a8140d322ddb9cf1ca57dbe24966a5 /Driver
parent21228b7753c6579d1ea273b52316239bf059ab75 (diff)
downloadclang-e8e260039346695beaa15af3e64ba38a64a1c30b.tar.gz
Add -emit-llvm-only option (generate LLVM IR & run passes, but discard
output). - For timing IRgen phase. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver')
-rw-r--r--Driver/ASTConsumers.h3
-rw-r--r--Driver/Backend.cpp3
-rw-r--r--Driver/clang.cpp8
3 files changed, 12 insertions, 2 deletions
diff --git a/Driver/ASTConsumers.h b/Driver/ASTConsumers.h
index 34c9fb246e..670f8dc190 100644
--- a/Driver/ASTConsumers.h
+++ b/Driver/ASTConsumers.h
@@ -48,7 +48,8 @@ ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
enum BackendAction {
Backend_EmitAssembly,
Backend_EmitBC,
- Backend_EmitLL
+ Backend_EmitLL,
+ Backend_EmitNothing
};
ASTConsumer *CreateBackendConsumer(BackendAction Action,
Diagnostic &Diags,
diff --git a/Driver/Backend.cpp b/Driver/Backend.cpp
index 8cffae0748..3c7c1bc028 100644
--- a/Driver/Backend.cpp
+++ b/Driver/Backend.cpp
@@ -181,6 +181,9 @@ FunctionPassManager *BackendConsumer::getPerFunctionPasses() const {
}
bool BackendConsumer::AddEmitPasses(std::string &Error) {
+ if (Action == Backend_EmitNothing)
+ return true;
+
if (OutputFile == "-" || (InputFile == "-" && OutputFile.empty())) {
AsmOutStream = new raw_stdout_ostream();
sys::Program::ChangeStdoutToBinary();
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index d17f77b0a8..6fdd18af6b 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -86,6 +86,7 @@ enum ProgActions {
EmitAssembly, // Emit a .s file.
EmitLLVM, // Emit a .ll file.
EmitBC, // Emit a .bc file.
+ EmitLLVMOnly, // Generate LLVM IR, but do not
SerializeAST, // Emit a .ast file.
EmitHTML, // Translate input source into HTML.
ASTPrint, // Parse ASTs and print them.
@@ -143,6 +144,8 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
"Build ASTs then convert to LLVM, emit .ll file"),
clEnumValN(EmitBC, "emit-llvm-bc",
"Build ASTs then convert to LLVM, emit .bc file"),
+ clEnumValN(EmitLLVMOnly, "emit-llvm-only",
+ "Build ASTs and convert to LLVM, discarding output"),
clEnumValN(SerializeAST, "serialize",
"Build ASTs and emit .ast file"),
clEnumValN(RewriteTest, "rewrite-test",
@@ -1297,12 +1300,15 @@ static ASTConsumer *CreateASTConsumer(const std::string& InFile,
case EmitAssembly:
case EmitLLVM:
- case EmitBC: {
+ case EmitBC:
+ case EmitLLVMOnly: {
BackendAction Act;
if (ProgAction == EmitAssembly)
Act = Backend_EmitAssembly;
else if (ProgAction == EmitLLVM)
Act = Backend_EmitLL;
+ else if (ProgAction == EmitLLVMOnly)
+ Act = Backend_EmitNothing;
else
Act = Backend_EmitBC;