<commit_before>//===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
//
// This family of functions is useful for performing dead code elimination of 
// various sorts.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_OPT_DCE_H
#define LLVM_OPT_DCE_H

#include "llvm/Pass.h"
#include "llvm/BasicBlock.h"

struct DeadCodeElimination : public MethodPass {
  // External Interface:
  //
  static bool doDCE(Method *M);

  // dceInstruction - Inspect the instruction at *BBI and figure out if it's
  // [trivially] dead.  If so, remove the instruction and update the iterator
  // to point to the instruction that immediately succeeded the original
  // instruction.
  //
  static bool dceInstruction(BasicBlock::InstListType &BBIL,
                             BasicBlock::iterator &BBI);

  // Remove unused global values - This removes unused global values of no
  // possible value.  This currently includes unused method prototypes and
  // unitialized global variables.
  //
  static bool RemoveUnusedGlobalValues(Module *M);

  // Pass Interface...
  virtual bool doInitialization(Module *M) {
    return RemoveUnusedGlobalValues(M);
  }
  virtual bool runOnMethod(Method *M) { return doDCE(M); }
  virtual bool doFinalization(Module *M) {
    return RemoveUnusedGlobalValues(M);
  }
};



struct AgressiveDCE : public MethodPass {
  // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
  //<commit_msg>* Expose new pass DeadInstElimination * Add comments that describe the differences between the DCE passes<commit_after>//===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
//
// This family of functions is useful for performing dead code elimination of 
// various sorts.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_OPT_DCE_H
#define LLVM_OPT_DCE_H

#include "llvm/Pass.h"
#include "llvm/BasicBlock.h"

//===----------------------------------------------------------------------===//
// DeadInstElimination - This pass quickly removes trivially dead instructions
// without modifying the CFG of the function.  It is a BasicBlockPass, so it
// runs efficiently when queued next to other BasicBlockPass's.
//
struct DeadInstElimination : public BasicBlockPass {
  virtual bool runOnBasicBlock(BasicBlock *BB);
};


//===----------------------------------------------------------------------===//
// DeadCodeElimination - This pass is more powerful than DeadInstElimination,
// because it will remove dead basic blocks as well as all of the instructions
// contained within them.  This pass is useful to run after another pass has
// reorganized the CFG and possibly modified control flow.
//
// TODO: In addition to DCE stuff, this also merges basic blocks together and
// otherwise simplifies control flow.  This should be factored out of this pass
// eventually into it's own pass.
//
struct DeadCodeElimination : public MethodPass {
  // External Interface:
  //
  static bool doDCE(Method *M);

  // dceInstruction - Inspect the instruction at *BBI and figure out if it's
  // [trivially] dead.  If so, remove the instruction and update the iterator
  // to point to the instruction that immediately succeeded the original
  // instruction.
  //
  static bool dceInstruction(BasicBlock::InstListType &BBIL,
                             BasicBlock::iterator &BBI);

  // Remove unused global values - This removes unused global values of no
  // possible value.  This currently includes unused method prototypes and
  // unitialized global variables.
  //
  static bool RemoveUnusedGlobalValues(Module *M);

  // Pass Interface...
  virtual bool doInitialization(Module *M) {
    return RemoveUnusedGlobalValues(M);
  }
  virtual bool runOnMethod(Method *M) { return doDCE(M); }
  virtual bool doFinalization(Module *M) {
    return RemoveUnusedGlobalValues(M);
  }
};



//===----------------------------------------------------------------------===//
// AgressiveDCE - This pass uses the SSA based Agressive DCE algorithm.  This
// algorithm assumes instructions are dead until proven otherwise, which makes
// it more successful are removing non-obviously dead instructions.
//
struct AgressiveDCE : public MethodPass {
  // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
  //
{'fraction_non_alphanumeric': 0.17036359478618798, 'fraction_numerical': 0.0, 'mean_word_length': 2.4305882352941177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6327609', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1110, 'n_words': 431}