Ignore:
Timestamp:
Sep 7, 2017, 4:56:56 PM (21 months ago)
Author:
nmedfort
Message:

Partial check-in for avoidance of compiling Pablo/LLVM code to determine the Kernel struct type when using a cached object. Inactive RE alternation minimization check in.

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

Legend:

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

    r5624 r5630  
    201201    if (LLVM_UNLIKELY(printRegister == nullptr)) {
    202202        FunctionType *FT = FunctionType::get(getVoidTy(), { getInt8PtrTy(), int64Ty }, false);
    203         Function * function = Function::Create(FT, Function::InternalLinkage, "PrintInt", m);
     203        Function * function = Function::Create(FT, Function::ExternalLinkage, "PrintInt", m);
    204204        auto arg = function->arg_begin();
    205205        std::string out = "%-40s = %" PRIx64 "\n";
     
    561561
    562562PointerType * CBuilder::getVoidPtrTy() const {
    563     return TypeBuilder<void *, true>::get(getContext());
     563    return TypeBuilder<void *, false>::get(getContext());
    564564}
    565565
     
    10501050}
    10511051
    1052 #define CONCAT(a__, b__) a__##b__
    1053 #define STRINGIFY(a__) #a__
    1054 
    10551052#ifdef HAS_ADDRESS_SANITIZER
    10561053#define CHECK_ADDRESS_SANITIZER(Ptr, Name) \
     
    10701067    Value * check = CreateCall(isPoisoned, { addr, size }); \
    10711068    check = CreateICmpEQ(check, ConstantPointerNull::get(cast<PointerType>(isPoisoned->getReturnType()))); \
    1072     CreateAssert(check, STRINGIFY(CONCAT(Name, ": invalid memory address"))); \
     1069    CreateAssert(check, Name ": invalid memory address"); \
    10731070}
    10741071#else
     
    10781075#define CHECK_ADDRESS(Ptr, Name) \
    10791076    if (codegen::EnableAsserts) { \
    1080         CreateAssert(Ptr, STRINGIFY(CONCAT(Name, ": null pointer address"))); \
     1077        CreateAssert(Ptr, Name ": null pointer address"); \
    10811078        CHECK_ADDRESS_SANITIZER(Ptr, Name) \
    10821079    }
     
    11611158}
    11621159
    1163 CallInst * CBuilder::CreateMemMove(Value * Dst, Value * Src, Value *Size, unsigned Align, bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) {
     1160CallInst * CBuilder::CreateMemMove(Value * Dst, Value * Src, Value *Size, unsigned Align, bool isVolatile,
     1161                                   MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) {
    11641162    if (codegen::EnableAsserts) {
    11651163        DataLayout DL(getModule());
     
    11671165        Value * intDst = CreatePtrToInt(Dst, intPtrTy);
    11681166        Value * intSrc = CreatePtrToInt(Src, intPtrTy);
     1167        // If the call to this intrinisic has an alignment value that is not 0 or 1, then the caller
     1168        // guarantees that both the source and destination pointers are aligned to that boundary.
    11691169        if (Align > 1) {
    11701170            ConstantInt * align = ConstantInt::get(intPtrTy, Align);
     
    11741174    }
    11751175    return IRBuilder<>::CreateMemMove(Dst, Src, Size, Align, isVolatile, TBAATag, ScopeTag, NoAliasTag);
     1176}
     1177
     1178llvm::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) {
     1180    if (codegen::EnableAsserts) {
     1181        DataLayout DL(getModule());
     1182        IntegerType * const intPtrTy = DL.getIntPtrType(getContext());
     1183        Value * intDst = CreatePtrToInt(Dst, intPtrTy);
     1184        Value * intSrc = CreatePtrToInt(Src, intPtrTy);
     1185        // If the call to this intrinisic has an alignment value that is not 0 or 1, then the caller
     1186        // guarantees that both the source and destination pointers are aligned to that boundary.
     1187        if (Align > 1) {
     1188            ConstantInt * align = ConstantInt::get(intPtrTy, Align);
     1189            CreateAssertZero(CreateURem(intDst, align), "CreateMemCpy: Dst pointer is misaligned");
     1190            CreateAssertZero(CreateURem(intSrc, align), "CreateMemCpy: Src pointer is misaligned");
     1191        }
     1192        Value * intSize = CreateZExtOrTrunc(Size, intSrc->getType());
     1193        Value * nonOverlapping = CreateOr(CreateICmpULT(CreateAdd(intSrc, intSize), intDst),
     1194                                          CreateICmpULT(CreateAdd(intDst, intSize), intSrc));
     1195        CreateAssert(nonOverlapping, "CreateMemCpy: overlapping ranges is undefined");
     1196    }
     1197    return IRBuilder<>::CreateMemCpy(Dst, Src, Size, Align, isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag);
    11761198}
    11771199
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5624 r5630  
    258258    llvm::StoreInst * CreateAlignedStore(llvm::Value * Val, llvm::Value * Ptr, unsigned Align, bool isVolatile = false);
    259259
     260    llvm::CallInst * CreateMemMove(llvm::Value *Dst, llvm::Value *Src, uint64_t Size, unsigned Align,
     261                            bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
     262                            llvm::MDNode *ScopeTag = nullptr,
     263                            llvm::MDNode *NoAliasTag = nullptr) {
     264        return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag, ScopeTag, NoAliasTag);
     265    }
     266
    260267    llvm::CallInst * CreateMemMove(llvm::Value *Dst, llvm::Value *Src, llvm::Value *Size, unsigned Align,
    261268                            bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
    262269                            llvm::MDNode *ScopeTag = nullptr,
    263270                            llvm::MDNode *NoAliasTag = nullptr);
     271
     272    llvm::CallInst * CreateMemCpy(llvm::Value *Dst, llvm::Value *Src, uint64_t Size, unsigned Align,
     273                           bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
     274                           llvm::MDNode *TBAAStructTag = nullptr,
     275                           llvm::MDNode *ScopeTag = nullptr,
     276                           llvm::MDNode *NoAliasTag = nullptr) {
     277        return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag);
     278    }
     279
     280    llvm::CallInst * CreateMemCpy(llvm::Value *Dst, llvm::Value *Src, llvm::Value *Size, unsigned Align,
     281                           bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
     282                           llvm::MDNode *TBAAStructTag = nullptr,
     283                           llvm::MDNode *ScopeTag = nullptr,
     284                           llvm::MDNode *NoAliasTag = nullptr);
     285
    264286
    265287    void setDriver(Driver * const driver) {
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.cpp

    r5486 r5630  
    210210  CreateCall(barrierFunc);
    211211
    212   Value * carryOffsetPtr = nullptr;
    213212  Value * carryVal = carryInitVal;
    214   Value * bubbleOffsetPtr = nullptr;
    215213  Value * bubbleVal = bubbleInitVal;
    216214
    217215  for (unsigned offset = groupThreads/2; offset>0; offset=offset>>1){
    218     carryOffsetPtr = CreateGEP(carry, {getInt32(0), CreateXor(id, getInt32(offset))});
     216    Value * carryOffsetPtr = CreateGEP(carry, {getInt32(0), CreateXor(id, getInt32(offset))});
    219217    carryVal = CreateOr(carryVal, CreateLoad(carryOffsetPtr));
    220218    CreateStore(carryVal, carryPtr);
    221     bubbleOffsetPtr = CreateGEP(bubble, {getInt32(0), CreateXor(id, getInt32(offset))});
     219    Value * bubbleOffsetPtr = CreateGEP(bubble, {getInt32(0), CreateXor(id, getInt32(offset))});
    222220    bubbleVal = CreateOr(bubbleVal, CreateLoad(bubbleOffsetPtr));
    223221    CreateStore(bubbleVal, bubblePtr);
Note: See TracChangeset for help on using the changeset viewer.