changeset 1576:4551475bc6b6

Kill off StripMetaData.
author Benjamin Kramer <benny.kra@gmail.com>
date Tue, 25 Aug 2009 21:35:43 +0200
parents 299a6b634178
children e4f7b5d9c68a
files gen/main.cpp gen/optimizer.cpp gen/passes/Passes.h gen/passes/StripMetaData.cpp
diffstat 4 files changed, 1 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/gen/main.cpp	Tue Aug 25 21:21:37 2009 +0200
+++ b/gen/main.cpp	Tue Aug 25 21:35:43 2009 +0200
@@ -938,13 +938,6 @@
         std::string errormsg;
         for (int i = 0; i < llvmModules.size(); i++)
         {
-#if USE_METADATA
-            //FIXME: workaround for llvm metadata bug:
-            //  the LinkInModule call asserts with metadata unstripped
-            llvm::ModulePass* stripMD = createStripMetaData();
-            stripMD->runOnModule(*llvmModules[i]);
-            delete stripMD;
-#endif // USE_METADATA
             if(linker.LinkInModule(llvmModules[i], &errormsg))
                 error("%s", errormsg.c_str());
             delete llvmModules[i];
--- a/gen/optimizer.cpp	Tue Aug 25 21:21:37 2009 +0200
+++ b/gen/optimizer.cpp	Tue Aug 25 21:35:43 2009 +0200
@@ -58,12 +58,6 @@
     cl::desc("Disable promotion of GC allocations to stack memory in -O<N>"),
     cl::ZeroOrMore);
 
-// Not recommended; metadata currently triggers an assert in the backend...
-static cl::opt<bool>
-disableStripMetaData("disable-strip-metadata",
-    cl::desc("Disable default metadata stripping (not recommended)"),
-    cl::ZeroOrMore);
-
 static cl::opt<opts::BoolOrDefaultAdapter, false, opts::FlagParser>
 enableInlining("inlining",
     cl::desc("(*) Enable function inlining in -O<N>"),
@@ -222,18 +216,8 @@
 // Returns true if any optimization passes were invoked.
 bool ldc_optimize_module(llvm::Module* m)
 {
-    if (!optimize()) {
-#if USE_METADATA
-        if (!disableStripMetaData) {
-            // This one always needs to run if metadata is generated, because
-            // the code generator will assert if it's not used.
-            ModulePass* stripMD = createStripMetaData();
-            stripMD->runOnModule(*m);
-            delete stripMD;
-        }
-#endif
+    if (!optimize())
         return false;
-    }
 
     PassManager pm;
     
@@ -270,14 +254,6 @@
     if (optimize)
         addPassesForOptLevel(pm);
 
-#if USE_METADATA
-    if (!disableStripMetaData) {
-        // This one is purposely not disabled by disableLangSpecificPasses
-        // because the code generator will assert if it's not used.
-        addPass(pm, createStripMetaData());
-    }
-#endif // USE_METADATA
-
     pm.run(*m);
     return true;
 }
--- a/gen/passes/Passes.h	Tue Aug 25 21:21:37 2009 +0200
+++ b/gen/passes/Passes.h	Tue Aug 25 21:35:43 2009 +0200
@@ -12,7 +12,6 @@
 
 #if USE_METADATA
 llvm::FunctionPass* createGarbageCollect2Stack();
-llvm::ModulePass* createStripMetaData();
 #endif // USE_METADATA
 
 llvm::ModulePass* createStripExternalsPass();
--- a/gen/passes/StripMetaData.cpp	Tue Aug 25 21:21:37 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#if USE_METADATA
-
-//===- StripMetaData - Strips D-specific metadata -------------------------===//
-//
-//                             The LLVM D Compiler
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// There's an issue with the new LLVM metadata support; an assertion fires when
-// trying to generate asm for metadata globals.
-//
-// This pass is a workaround; it deletes the metadata LDC generates so the code
-// generator doesn't see it.
-// Obviously, this should only run after all passes that make use of that
-// metadata or they won't work.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gen/metadata.h"
-
-#define DEBUG_TYPE "strip-metadata"
-
-#include "Passes.h"
-
-#include "llvm/Pass.h"
-#include "llvm/Module.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-STATISTIC(NumDeleted, "Number of metadata globals deleted");
-
-//===----------------------------------------------------------------------===//
-// StripMetaData Pass Implementation
-//===----------------------------------------------------------------------===//
-
-namespace {
-    /// This pass optimizes library functions from the D runtime as used by LDC.
-    ///
-    class VISIBILITY_HIDDEN StripMetaData : public ModulePass {
-        public:
-        static char ID; // Pass identification
-        StripMetaData() : ModulePass(&ID) {}
-        
-        bool runOnModule(Module &M);
-    };
-    char StripMetaData::ID = 0;
-} // end anonymous namespace.
-
-static RegisterPass<StripMetaData>
-X("strip-metadata", "Delete D-specific metadata");
-
-// Public interface to the pass.
-ModulePass *createStripMetaData() {
-  return new StripMetaData(); 
-}
-
-/// runOnFunction - Top level algorithm.
-///
-bool StripMetaData::runOnModule(Module &M) {
-    bool Changed = false;
-    for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E;) {
-        GlobalVariable* G = I++;
-        if (G->getName().startswith("llvm.ldc.")) {
-            assert(G->hasInitializer() && isa<MDNode>(G->getInitializer())
-                && "Not a metadata global?");
-            Changed = true;
-            NumDeleted++;
-            DEBUG(errs() << "Deleting " << *G << '\n');
-            G->eraseFromParent();
-        }
-    }
-    return Changed;
-}
-
-#endif // USE_METADATA