[cfe-commits] r105576 - in /cfe/trunk: include/clang/Frontend/BackendUtil.h lib/Frontend/BackendUtil.cpp lib/Frontend/CodeGenAction.cpp

Daniel Dunbar daniel at zuster.org
Mon Jun 7 16:21:04 PDT 2010


Author: ddunbar
Date: Mon Jun  7 18:21:04 2010
New Revision: 105576

URL: http://llvm.org/viewvc/llvm-project?rev=105576&view=rev
Log:
Frontend: Drop unnecessary TargetData argument to EmitBackendOutput, we always
create modules which have target data strings.

Modified:
    cfe/trunk/include/clang/Frontend/BackendUtil.h
    cfe/trunk/lib/Frontend/BackendUtil.cpp
    cfe/trunk/lib/Frontend/CodeGenAction.cpp

Modified: cfe/trunk/include/clang/Frontend/BackendUtil.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/BackendUtil.h?rev=105576&r1=105575&r2=105576&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/BackendUtil.h (original)
+++ cfe/trunk/include/clang/Frontend/BackendUtil.h Mon Jun  7 18:21:04 2010
@@ -9,7 +9,6 @@
 
 namespace llvm {
   class Module;
-  class TargetData;
   class raw_ostream;
 }
 
@@ -28,7 +27,6 @@
   };
   
   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);
 }

Modified: cfe/trunk/lib/Frontend/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/BackendUtil.cpp?rev=105576&r1=105575&r2=105576&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/BackendUtil.cpp (original)
+++ cfe/trunk/lib/Frontend/BackendUtil.cpp Mon Jun  7 18:21:04 2010
@@ -39,7 +39,6 @@
   const CodeGenOptions &CodeGenOpts;
   const TargetOptions &TargetOpts;
   Module *TheModule;
-  TargetData *TheTargetData;
 
   Timer CodeGenerationTime;
 
@@ -51,7 +50,7 @@
   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 @@
   PassManager *getPerModulePasses() const {
     if (!PerModulePasses) {
       PerModulePasses = new PassManager();
-      PerModulePasses->add(new TargetData(*TheTargetData));
+      PerModulePasses->add(new TargetData(TheModule));
     }
     return PerModulePasses;
   }
@@ -67,7 +66,7 @@
   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 @@
 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 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);
 }

Modified: cfe/trunk/lib/Frontend/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CodeGenAction.cpp?rev=105576&r1=105575&r2=105576&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/Frontend/CodeGenAction.cpp Mon Jun  7 18:21:04 2010
@@ -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 @@
     llvm::OwningPtr<CodeGenerator> Gen;
 
     llvm::OwningPtr<llvm::Module> TheModule;
-    llvm::TargetData *TheTargetData;
 
   public:
     BackendConsumer(BackendAction action, Diagnostic &_Diags,
@@ -56,15 +55,10 @@
       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 @@
       Gen->Initialize(Ctx);
 
       TheModule.reset(Gen->GetModule());
-      TheTargetData = new llvm::TargetData(Ctx.Target.getTargetDescription());
 
       if (llvm::TimePassesIsEnabled)
         LLVMIRGeneration.stopTimer();
@@ -109,7 +102,7 @@
       }
 
       // 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 @@
                                         this);
 
       EmitBackendOutput(Diags, CodeGenOpts, TargetOpts,
-                        TheModule.get(), TheTargetData, Action, AsmOutStream);
+                        TheModule.get(), Action, AsmOutStream);
       
       Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
     }





More information about the cfe-commits mailing list