Ignore:
Timestamp:
Oct 4, 2016, 6:05:21 AM (3 years ago)
Author:
cameron
Message:

Engine deletion causes segfaults with LLVM 3.9 changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5165 r5176  
    4141#include "llvm/IRReader/IRReader.h"
    4242#include "llvm/Linker/Linker.h"
    43 
     43#include "llvm-c/Core.h"
    4444
    4545#include <fstream>
     
    7575static cl::OptionCategory bGrepOutputOptions("Output Options",
    7676                                             "These options control the output.");
     77static cl::opt<bool> SilenceFileErrors("s", cl::desc("Suppress messages for file errors."), cl::init(false),  cl::cat(bGrepOutputOptions));
     78
     79static cl::opt<bool> SuppressOutput("q", cl::desc("Suppress normal output; set return code only."), cl::init(false),  cl::cat(bGrepOutputOptions));
    7780
    7881static cl::opt<bool> NormalizeLineBreaks("normalize-line-breaks", cl::desc("Normalize line breaks to std::endl."), cl::init(false),  cl::cat(bGrepOutputOptions));
     
    99102        }
    100103    } else {
    101         std::cerr << "Error: cannot open " << fileName << " for processing. Skipped.\n";
    102         return;
     104        if (!SilenceFileErrors) {
     105            std::cerr << "Error: cannot open " << fileName << " for processing. Skipped.\n";
     106            return;
     107        }
    103108    }
    104109
     
    128133            source.close();
    129134        } catch (std::exception & e) {
    130             throw std::runtime_error("Boost mmap error: " + fileName + ": " + e.what());
     135            if (!SilenceFileErrors) {
     136                std::cerr << "Boost mmap error: " + fileName + ": " + e.what() + " Skipped.\n";
     137                return;
     138            }
    131139        }
    132140    } else {
     
    225233    int addrSpace = 0;
    226234    bool CPU_Only = true;
    227 
    228     Module * cpuM = new Module(moduleName+":cpu", getGlobalContext());
     235    LLVMContext TheContext;
     236    Module * cpuM = new Module(moduleName+":cpu", TheContext);
    229237    IDISA::IDISA_Builder * CPUBuilder = IDISA::GetIDISA_Builder(cpuM);
    230238    Module * M = cpuM; 
     
    234242    setNVPTXOption();
    235243    if(codegen::NVPTX){     
    236         Module * gpuM = new Module(moduleName+":gpu", getGlobalContext());
     244        Module * gpuM = new Module(moduleName+":gpu", TheContext);
    237245        IDISA::IDISA_Builder * GPUBuilder = IDISA::GetIDISA_GPU_Builder(gpuM);
    238246        M = gpuM;
     
    464472
    465473GrepEngine::~GrepEngine() {
    466     delete mEngine;
     474//    delete mEngine;
    467475}
    468476
     
    548556
    549557void PrintResult(bool CountOnly, std::vector<size_t> & total_CountOnly){
     558   
    550559    if(CountOnly){
    551560        if (!ShowFileNames) {
Note: See TracChangeset for help on using the changeset viewer.