Ignore:
Timestamp:
May 16, 2017, 4:13:53 PM (2 years ago)
Author:
nmedfort
Message:

Bug fix check in for DumpTrace?, compilation of DoBlock? / DoFinalBlock? functions. Pablo CodeMotionPass? optimized and enabled by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/source_kernel.cpp

    r5440 r5454  
    8181    // instruct the OS that it can safely drop any fully consumed pages
    8282    Value * consumed = iBuilder->getConsumedItemCount("sourceBuffer");
    83     Type * const consumedTy = consumed->getType();
     83    IntegerType * const consumedTy = cast<IntegerType>(consumed->getType());
    8484    Type * const voidPtrTy = iBuilder->getVoidPtrTy();
     85
     86    DataLayout DL(iBuilder->getModule());
     87    IntegerType * const intAddrTy = iBuilder->getIntPtrTy(DL);
    8588
    8689    // multiply the consumed count by the code unit size then mask off any partial pages
    8790    if (mCodeUnitWidth > 8) {
    88         consumed = iBuilder->CreateMul(consumed, iBuilder->getSize(mCodeUnitWidth / 8));
     91        consumed = iBuilder->CreateMul(consumed, ConstantInt::get(consumedTy, mCodeUnitWidth / 8));
    8992    }
    9093    const auto pageSize = getpagesize();
     
    9497        consumed = iBuilder->CreateSub(consumed, iBuilder->CreateURem(consumed, ConstantInt::get(consumedTy, pageSize)));
    9598    }
     99
    96100    Value * sourceBuffer = iBuilder->getBaseAddress("sourceBuffer");
    97     sourceBuffer = iBuilder->CreatePtrToInt(sourceBuffer, consumedTy);
     101    sourceBuffer = iBuilder->CreatePtrToInt(sourceBuffer, intAddrTy);
     102    if (LLVM_UNLIKELY(intAddrTy->getBitWidth() > consumedTy->getBitWidth())) {
     103        consumed = iBuilder->CreateZExt(consumed, intAddrTy);
     104    } else if (LLVM_UNLIKELY(intAddrTy->getBitWidth() < consumedTy->getBitWidth())) {
     105        sourceBuffer = iBuilder->CreateZExt(sourceBuffer, consumedTy);
     106    }
    98107    Value * consumedBuffer = iBuilder->CreateAdd(sourceBuffer, consumed);
    99 
    100 
    101 
    102 
    103108    Value * readableBuffer = iBuilder->getScalarField("readableBuffer");
    104     readableBuffer = iBuilder->CreatePtrToInt(readableBuffer, consumedTy);
     109    readableBuffer = iBuilder->CreatePtrToInt(readableBuffer, consumedBuffer->getType());
    105110    Value * unnecessaryBytes = iBuilder->CreateSub(consumedBuffer, readableBuffer);
    106111
    107 
    108 
    109112    // avoid calling madvise unless an actual page table change could occur
    110     Value * hasPagesToDrop = iBuilder->CreateICmpEQ(unnecessaryBytes, ConstantInt::getNullValue(unnecessaryBytes->getType()));
     113    Value * hasPagesToDrop = iBuilder->CreateICmpEQ(unnecessaryBytes, ConstantInt::getNullValue(intAddrTy));
    111114    iBuilder->CreateLikelyCondBr(hasPagesToDrop, processSegment, dropPages);
    112115
Note: See TracChangeset for help on using the changeset viewer.