Frontend: Drop unnecessary TargetData argument to EmitBackendOutput, we always

create modules which have target data strings.

llvm-svn: 105576
This commit is contained in:
Daniel Dunbar 2010-06-07 23:21:04 +00:00
parent f976d1b205
commit 3e11152de3
3 changed files with 12 additions and 24 deletions

View File

@ -9,7 +9,6 @@
namespace llvm {
class Module;
class TargetData;
class raw_ostream;
}
@ -28,7 +27,6 @@ namespace clang {
};
void EmitBackendOutput(Diagnostic &Diags, const CodeGenOptions &CGOpts,
const TargetOptions &TOpts,
llvm::Module *M, llvm::TargetData *TD,
const TargetOptions &TOpts, llvm::Module *M,
BackendAction Action, llvm::raw_ostream *OS);
}

View File

@ -39,7 +39,6 @@ class EmitAssemblyHelper {
const CodeGenOptions &CodeGenOpts;
const TargetOptions &TargetOpts;
Module *TheModule;
TargetData *TheTargetData;
Timer CodeGenerationTime;
@ -51,7 +50,7 @@ private:
FunctionPassManager *getCodeGenPasses() const {
if (!CodeGenPasses) {
CodeGenPasses = new FunctionPassManager(TheModule);
CodeGenPasses->add(new TargetData(*TheTargetData));
CodeGenPasses->add(new TargetData(TheModule));
}
return CodeGenPasses;
}
@ -59,7 +58,7 @@ private:
PassManager *getPerModulePasses() const {
if (!PerModulePasses) {
PerModulePasses = new PassManager();
PerModulePasses->add(new TargetData(*TheTargetData));
PerModulePasses->add(new TargetData(TheModule));
}
return PerModulePasses;
}
@ -67,7 +66,7 @@ private:
FunctionPassManager *getPerFunctionPasses() const {
if (!PerFunctionPasses) {
PerFunctionPasses = new FunctionPassManager(TheModule);
PerFunctionPasses->add(new TargetData(*TheTargetData));
PerFunctionPasses->add(new TargetData(TheModule));
}
return PerFunctionPasses;
}
@ -82,10 +81,9 @@ private:
public:
EmitAssemblyHelper(Diagnostic &_Diags,
const CodeGenOptions &CGOpts, const TargetOptions &TOpts,
Module *M, TargetData *TD)
Module *M)
: Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts),
TheModule(M), TheTargetData(TD),
CodeGenerationTime("Code Generation Time"),
TheModule(M), CodeGenerationTime("Code Generation Time"),
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {}
~EmitAssemblyHelper() {
@ -320,9 +318,8 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) {
void clang::EmitBackendOutput(Diagnostic &Diags, const CodeGenOptions &CGOpts,
const TargetOptions &TOpts, Module *M,
TargetData *TD, BackendAction Action,
raw_ostream *OS) {
EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, M, TD);
BackendAction Action, raw_ostream *OS) {
EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, M);
AsmHelper.EmitAssembly(Action, OS);
}

View File

@ -20,11 +20,11 @@
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/Timer.h"
#include "llvm/Target/TargetData.h"
using namespace clang;
using namespace llvm;
@ -42,7 +42,6 @@ namespace {
llvm::OwningPtr<CodeGenerator> Gen;
llvm::OwningPtr<llvm::Module> TheModule;
llvm::TargetData *TheTargetData;
public:
BackendConsumer(BackendAction action, Diagnostic &_Diags,
@ -56,15 +55,10 @@ namespace {
TargetOpts(targetopts),
AsmOutStream(OS),
LLVMIRGeneration("LLVM IR Generation Time"),
Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)),
TheTargetData(0) {
Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)) {
llvm::TimePassesIsEnabled = TimePasses;
}
~BackendConsumer() {
delete TheTargetData;
}
llvm::Module *takeModule() { return TheModule.take(); }
virtual void Initialize(ASTContext &Ctx) {
@ -76,7 +70,6 @@ namespace {
Gen->Initialize(Ctx);
TheModule.reset(Gen->GetModule());
TheTargetData = new llvm::TargetData(Ctx.Target.getTargetDescription());
if (llvm::TimePassesIsEnabled)
LLVMIRGeneration.stopTimer();
@ -109,7 +102,7 @@ namespace {
}
// Silently ignore if we weren't initialized for some reason.
if (!TheModule || !TheTargetData)
if (!TheModule)
return;
// Make sure IR generation is happy with the module. This is released by
@ -134,7 +127,7 @@ namespace {
this);
EmitBackendOutput(Diags, CodeGenOpts, TargetOpts,
TheModule.get(), TheTargetData, Action, AsmOutStream);
TheModule.get(), Action, AsmOutStream);
Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
}