Changeset 5633


Ignore:
Timestamp:
Sep 10, 2017, 11:24:44 PM (2 months ago)
Author:
nmedfort
Message:

Bug fix to avoid a LLVM bug when using a cross-compilable void pointer type on 32-bit VMs running on a 64-bit host.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5630 r5633  
    201201    if (LLVM_UNLIKELY(printRegister == nullptr)) {
    202202        FunctionType *FT = FunctionType::get(getVoidTy(), { getInt8PtrTy(), int64Ty }, false);
    203         Function * function = Function::Create(FT, Function::ExternalLinkage, "PrintInt", m);
     203        Function * function = Function::Create(FT, Function::InternalLinkage, "PrintInt", m);
    204204        auto arg = function->arg_begin();
    205205        std::string out = "%-40s = %" PRIx64 "\n";
     
    561561
    562562PointerType * CBuilder::getVoidPtrTy() const {
    563     return TypeBuilder<void *, false>::get(getContext());
     563    return TypeBuilder<void *, true>::get(getContext());
    564564}
    565565
     
    664664    if (pthreadCreateFunc == nullptr) {
    665665        Type * pthreadTy = getSizeTy();
    666         FunctionType * funVoidPtrVoidTy = FunctionType::get(getVoidTy(), {getVoidPtrTy()}, false);
     666        FunctionType * funVoidPtrVoidTy = FunctionType::get(getVoidTy(), {voidPtrTy}, false);
    667667        FunctionType * fty = FunctionType::get(getInt32Ty(), {pthreadTy->getPointerTo(), voidPtrTy, funVoidPtrVoidTy->getPointerTo(), voidPtrTy}, false);
    668668        pthreadCreateFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_create", m);
     
    10791079    }
    10801080
    1081 LoadInst * CBuilder::CreateLoad(Value *Ptr, const char * Name) {
     1081LoadInst * CBuilder::CreateLoad(Value *Ptr, const char * Name) {   
    10821082    CHECK_ADDRESS(Ptr, "CreateLoad");
    10831083    return IRBuilder<>::CreateLoad(Ptr, Name);
     
    11001100
    11011101StoreInst * CBuilder::CreateStore(Value * Val, Value * Ptr, bool isVolatile) {
     1102    assert (Val->getType()->getPointerTo() == Ptr->getType());
    11021103    CHECK_ADDRESS(Ptr, "CreateStore");
    11031104    return IRBuilder<>::CreateStore(Val, Ptr, isVolatile);
     
    11761177}
    11771178
    1178 llvm::CallInst * CBuilder::CreateMemCpy(llvm::Value *Dst, llvm::Value *Src, llvm::Value *Size, unsigned Align, bool isVolatile,
    1179                                         llvm::MDNode *TBAATag, llvm::MDNode *TBAAStructTag, llvm::MDNode *ScopeTag, llvm::MDNode *NoAliasTag) {
     1179CallInst * CBuilder::CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile,
     1180                                  MDNode *TBAATag, MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) {
    11801181    if (codegen::EnableAsserts) {
    11811182        DataLayout DL(getModule());
  • icGREP/icgrep-devel/icgrep/kernels/source_kernel.cpp

    r5513 r5633  
    6464    size->addIncoming(pageSize, emptyFile);
    6565    size->addIncoming(fileSize, nonEmptyFile);
    66     kb->setBaseAddress("sourceBuffer", buffer);
     66    Value * bufferPtr = kb->CreatePointerCast(buffer, kb->getInt8PtrTy());
     67    kb->setBaseAddress("sourceBuffer", bufferPtr);
    6768    kb->setBufferedSize("sourceBuffer", size);
    68     kb->setScalarField("readableBuffer", buffer);
     69    kb->setScalarField("readableBuffer", bufferPtr);
    6970    kb->setScalarField("fileSize", fileSize);
    7071    kb->setCapacity("sourceBuffer", fileSize);
     
    8384    Value * consumed = kb->getConsumedItemCount("sourceBuffer");
    8485    IntegerType * const consumedTy = cast<IntegerType>(consumed->getType());
    85     Type * const voidPtrTy = kb->getVoidPtrTy();
     86    Type * const int8PtrTy = kb->getInt8PtrTy();
    8687
    8788    DataLayout DL(kb->getModule());
     
    116117
    117118    kb->SetInsertPoint(dropPages);
    118     kb->CreateMAdvise(kb->CreateIntToPtr(readableBuffer, voidPtrTy), unnecessaryBytes, CBuilder::ADVICE_DONTNEED);
    119     readableBuffer = kb->CreateIntToPtr(kb->CreateAdd(readableBuffer, unnecessaryBytes), voidPtrTy);
     119    kb->CreateMAdvise(kb->CreateIntToPtr(readableBuffer, int8PtrTy), unnecessaryBytes, CBuilder::ADVICE_DONTNEED);
     120    readableBuffer = kb->CreateIntToPtr(kb->CreateAdd(readableBuffer, unnecessaryBytes), int8PtrTy);
    120121    kb->setScalarField("readableBuffer", readableBuffer);
    121122    kb->CreateBr(processSegment);
     
    150151{Binding{kb->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
    151152{Binding{kb->getInt32Ty(), "fileDescriptor"}},
    152 {Binding{kb->getSizeTy(), "fileSize"}}, {Binding{kb->getVoidPtrTy(), "readableBuffer"}})
     153{Binding{kb->getSizeTy(), "fileSize"}}, {Binding{kb->getInt8PtrTy(), "readableBuffer"}})
    153154, mSegmentBlocks(blocksPerSegment)
    154155, mCodeUnitWidth(codeUnitWidth)
     
    344345
    345346void MemorySourceKernel::generateInitializeMethod(const std::unique_ptr<KernelBuilder> & kb) {
    346     kb->setBaseAddress("sourceBuffer", kb->CreatePointerCast(kb->getScalarField("fileSource"), kb->getVoidPtrTy()));
     347    kb->setBaseAddress("sourceBuffer", kb->CreatePointerCast(kb->getScalarField("fileSource"), kb->getInt8Ty()));
    347348    kb->setBufferedSize("sourceBuffer", kb->getScalarField("fileSize"));
    348349    kb->setCapacity("sourceBuffer", kb->getScalarField("fileSize"));
Note: See TracChangeset for help on using the changeset viewer.