Ignore:
Timestamp:
Nov 4, 2018, 5:32:24 PM (9 months ago)
Author:
nmedfort
Message:

Bug fixes for 32-bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain/cpudriver.cpp

    r6187 r6189  
    7272    InitializeNativeTarget();
    7373    InitializeNativeTargetAsmPrinter();
    74     InitializeNativeTargetAsmParser();
     74//    InitializeNativeTargetAsmParser();
    7575    llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
    7676   
     
    162162}
    163163
    164 void CPUDriver::preparePassManager() {
     164inline legacy::PassManager CPUDriver::preparePassManager() {
     165
     166    legacy::PassManager PM;
     167
    165168    PassRegistry * Registry = PassRegistry::getPassRegistry();
    166169    initializeCore(*Registry);
     
    170173    if (LLVM_UNLIKELY(codegen::ShowUnoptimizedIROption != codegen::OmittedOption)) {
    171174        if (LLVM_LIKELY(mIROutputStream == nullptr)) {
    172             if (codegen::ShowUnoptimizedIROption != "") {
     175            if (!codegen::ShowUnoptimizedIROption.empty()) {
    173176                std::error_code error;
    174177                mUnoptimizedIROutputStream = make_unique<raw_fd_ostream>(codegen::ShowUnoptimizedIROption, error, sys::fs::OpenFlags::F_None);
     
    177180            }
    178181        }
    179         mPassManager.add(createPrintModulePass(*mUnoptimizedIROutputStream));
     182        PM.add(createPrintModulePass(*mUnoptimizedIROutputStream));
    180183    }
    181184    if (IN_DEBUG_MODE || LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::VerifyIR))) {
    182         mPassManager.add(createVerifierPass());
    183     }
    184 
    185     mPassManager.add(createDeadCodeEliminationPass());        // Eliminate any trivially dead code
    186     mPassManager.add(createPromoteMemoryToRegisterPass());    // Promote stack variables to constants or PHI nodes
    187     mPassManager.add(createCFGSimplificationPass());          // Remove dead basic blocks and unnecessary branch statements / phi nodes
    188     mPassManager.add(createEarlyCSEPass());                   // Simple common subexpression elimination pass
    189     mPassManager.add(createInstructionCombiningPass());       // Simple peephole optimizations and bit-twiddling.
    190     mPassManager.add(createReassociatePass());                // Canonicalizes commutative expressions
    191     mPassManager.add(createGVNPass());                        // Global value numbering redundant expression elimination pass
    192     mPassManager.add(createCFGSimplificationPass());          // Repeat CFG Simplification to "clean up" any newly found redundant phi nodes
     185        PM.add(createVerifierPass());
     186    }
     187    PM.add(createDeadCodeEliminationPass());        // Eliminate any trivially dead code
     188    PM.add(createPromoteMemoryToRegisterPass());    // Promote stack variables to constants or PHI nodes
     189    PM.add(createCFGSimplificationPass());          // Remove dead basic blocks and unnecessary branch statements / phi nodes
     190    PM.add(createEarlyCSEPass());                   // Simple common subexpression elimination pass
     191    PM.add(createInstructionCombiningPass());       // Simple peephole optimizations and bit-twiddling.
     192    PM.add(createReassociatePass());                // Canonicalizes commutative expressions
     193    PM.add(createGVNPass());                        // Global value numbering redundant expression elimination pass
     194    PM.add(createCFGSimplificationPass());          // Repeat CFG Simplification to "clean up" any newly found redundant phi nodes
    193195    if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
    194         mPassManager.add(createRemoveRedundantAssertionsPass());
    195         mPassManager.add(createDeadCodeEliminationPass());
    196         mPassManager.add(createCFGSimplificationPass());
    197     }
    198 
     196        PM.add(createRemoveRedundantAssertionsPass());
     197        PM.add(createDeadCodeEliminationPass());
     198        PM.add(createCFGSimplificationPass());
     199    }
    199200    if (LLVM_UNLIKELY(codegen::ShowIROption != codegen::OmittedOption)) {
    200201        if (LLVM_LIKELY(mIROutputStream == nullptr)) {
    201             if (codegen::ShowIROption != "") {
     202            if (!codegen::ShowIROption.empty()) {
    202203                std::error_code error;
    203204                mIROutputStream = make_unique<raw_fd_ostream>(codegen::ShowIROption, error, sys::fs::OpenFlags::F_None);
     
    206207            }
    207208        }
    208         mPassManager.add(createPrintModulePass(*mIROutputStream));
    209     }
    210    
    211 #if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
     209        PM.add(createPrintModulePass(*mIROutputStream));
     210    }
     211    #if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 7, 0)
    212212    if (LLVM_UNLIKELY(codegen::ShowASMOption != codegen::OmittedOption)) {
    213         if (codegen::ShowASMOption != "") {
     213        if (!codegen::ShowASMOption.empty()) {
    214214            std::error_code error;
    215215            mASMOutputStream = make_unique<raw_fd_ostream>(codegen::ShowASMOption, error, sys::fs::OpenFlags::F_None);
     
    217217            mASMOutputStream = make_unique<raw_fd_ostream>(STDERR_FILENO, false, true);
    218218        }
    219         if (LLVM_UNLIKELY(mTarget->addPassesToEmitFile(mPassManager, *mASMOutputStream, TargetMachine::CGFT_AssemblyFile))) {
     219        if (LLVM_UNLIKELY(mTarget->addPassesToEmitFile(PM, *mASMOutputStream, TargetMachine::CGFT_AssemblyFile))) {
    220220            report_fatal_error("LLVM error: could not add emit assembly pass");
    221221        }
    222222    }
    223 #endif
     223    #endif
     224    return PM;
    224225}
    225226
    226227void CPUDriver::generateUncachedKernels() {
    227228    if (mUncachedKernel.empty()) return;
    228     preparePassManager();
     229    auto PM = preparePassManager();
    229230    for (auto & kernel : mUncachedKernel) {
    230231        kernel->prepareKernel(iBuilder);
     
    235236        Module * const module = kernel->getModule(); assert (module);
    236237        module->setTargetTriple(mMainModule->getTargetTriple());
    237         mPassManager.run(*module);
     238        PM.run(*module);
    238239        mCachedKernel.emplace_back(kernel.release());
    239240    }
     
    270271
    271272    iBuilder->setModule(mMainModule);
    272     mPassManager.run(*mMainModule);
    273273    #ifdef ORCJIT
    274274    std::vector<std::unique_ptr<Module>> moduleSet;
Note: See TracChangeset for help on using the changeset viewer.