Changeset 5932 for icGREP/icgrep-devel


Ignore:
Timestamp:
Mar 24, 2018, 10:30:59 AM (12 months ago)
Author:
cameron
Message:

Avoid segfault issue with -ShowASM

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

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

    r5927 r5932  
    8080void grepBuffer(re::RE * pattern, const char * search_buffer, size_t bufferLength, MatchAccumulator * accum) {
    8181    const unsigned segmentSize = codegen::BufferSegments * codegen::SegmentSize * codegen::ThreadNum;
     82    auto segParallelModeSave = codegen::SegmentPipelineParallel;
     83    codegen::SegmentPipelineParallel = false;
    8284   
    8385    pattern = resolveCaseInsensitiveMode(pattern, false);
     
    141143    auto f = reinterpret_cast<GrepFunctionType>(pxDriver.getMain());
    142144    f(search_buffer, bufferLength);
     145    codegen::SegmentPipelineParallel = segParallelModeSave;
    143146}
    144147
  • icGREP/icgrep-devel/icgrep/toolchain/cpudriver.cpp

    r5928 r5932  
    6666#endif
    6767, mCache(nullptr)
     68, mUnoptimizedIROutputStream(nullptr)
    6869, mIROutputStream(nullptr)
    6970, mASMOutputStream(nullptr) {
     
    214215            if (codegen::ShowUnoptimizedIROption != "") {
    215216                std::error_code error;
    216                 mIROutputStream = new raw_fd_ostream(codegen::ShowUnoptimizedIROption, error, sys::fs::OpenFlags::F_None);
     217                mUnoptimizedIROutputStream = make_unique<raw_fd_ostream>(codegen::ShowUnoptimizedIROption, error, sys::fs::OpenFlags::F_None);
    217218            } else {
    218                 mIROutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
     219                mUnoptimizedIROutputStream = make_unique<raw_fd_ostream>(STDERR_FILENO, false, true);
    219220            }
    220221        }
    221         mPassManager.add(createPrintModulePass(*mIROutputStream));
     222        mPassManager.add(createPrintModulePass(*mUnoptimizedIROutputStream));
    222223    }
    223224    if (IN_DEBUG_MODE || LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::VerifyIR))) {
     
    236237            if (codegen::ShowIROption != "") {
    237238                std::error_code error;
    238                 mIROutputStream = new raw_fd_ostream(codegen::ShowIROption, error, sys::fs::OpenFlags::F_None);
     239                mIROutputStream = make_unique<raw_fd_ostream>(codegen::ShowIROption, error, sys::fs::OpenFlags::F_None);
    239240            } else {
    240                 mIROutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
     241                mIROutputStream = make_unique<raw_fd_ostream>(STDERR_FILENO, false, true);
    241242            }
    242243        }
     
    248249        if (codegen::ShowASMOption != "") {
    249250            std::error_code error;
    250             mASMOutputStream = new raw_fd_ostream(codegen::ShowASMOption, error, sys::fs::OpenFlags::F_None);
     251            mASMOutputStream = make_unique<raw_fd_ostream>(codegen::ShowASMOption, error, sys::fs::OpenFlags::F_None);
    251252        } else {
    252             mASMOutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
     253            mASMOutputStream = make_unique<raw_fd_ostream>(STDERR_FILENO, false, true);
    253254        }
    254255        if (LLVM_UNLIKELY(mTarget->addPassesToEmitFile(mPassManager, *mASMOutputStream, TargetMachine::CGFT_AssemblyFile))) {
     
    347348    delete mCache;
    348349    delete mTarget;
    349     delete mIROutputStream;
    350     delete mASMOutputStream;
    351350 }
  • icGREP/icgrep-devel/icgrep/toolchain/cpudriver.h

    r5924 r5932  
    6262
    6363    llvm::TargetMachine *                                   mTarget;
    64     llvm::legacy::PassManager                               mPassManager;
    6564
    6665#ifdef ORCJIT
     
    7372    ParabixObjectCache *                                    mCache;
    7473    std::vector<kernel::Kernel *>                           mUncachedKernel;
    75     // NOTE: when printing the IR/ASM, we cannot assume they're completely finished after finalizeObject is executed. Instead we store a
    76     // pointer and delete them once the driver (and any processing) is complete. This prevents us from reclaiming the memory early but
    77     // also avoids a potential segmentation fault when writing large files.
    78     llvm::raw_fd_ostream *                                  mIROutputStream;
    79     llvm::raw_fd_ostream *                                  mASMOutputStream;
     74    std::unique_ptr<llvm::raw_fd_ostream>                   mUnoptimizedIROutputStream;
     75    std::unique_ptr<llvm::raw_fd_ostream>                   mIROutputStream;
     76    std::unique_ptr<llvm::raw_fd_ostream>                   mASMOutputStream;
     77    llvm::legacy::PassManager                               mPassManager;
    8078};
    8179
Note: See TracChangeset for help on using the changeset viewer.