From 7d0121ea27441b8f36a9d67928405cb1b7bb62e6 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 7 Feb 2022 15:35:00 -0500 Subject: [PATCH] Explicit 64-bit indexer truncation on 32-bit builds --- IDEHelper/Compiler/BfIRCodeGen.cpp | 10 +++++++++- IDEHelper/Compiler/BfIRCodeGen.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index 76c3ba11..e94218f6 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -486,6 +486,12 @@ void BfIRCodeGen::FixValues(llvm::StructType* structType, llvm::SmallVectorgetType()->getScalarSizeInBits() > mPtrSize * 8) + val = mIRBuilder->CreateIntCast(val, llvm::Type::getInt32Ty(*mLLVMContext), false); +} + BfTypeCode BfIRCodeGen::GetTypeCode(llvm::Type* type, bool isSigned) { if (type->isIntegerTy()) @@ -2340,7 +2346,7 @@ void BfIRCodeGen::HandleNextCmd() SetResult(curId, mIRBuilder->CreateBitCast(gepResult, val->getType())); break; } - + FixIndexer(idx0); SetResult(curId, mIRBuilder->CreateInBoundsGEP(val, idx0)); } break; @@ -2349,6 +2355,8 @@ void BfIRCodeGen::HandleNextCmd() CMD_PARAM(llvm::Value*, val); CMD_PARAM(llvm::Value*, idx0); CMD_PARAM(llvm::Value*, idx1); + FixIndexer(idx0); + FixIndexer(idx1); llvm::Value* indices[2] = { idx0, idx1 }; SetResult(curId, FixGEP(val, mIRBuilder->CreateInBoundsGEP(val, llvm::makeArrayRef(indices)))); } diff --git a/IDEHelper/Compiler/BfIRCodeGen.h b/IDEHelper/Compiler/BfIRCodeGen.h index 2fcda96f..b2c7721c 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.h +++ b/IDEHelper/Compiler/BfIRCodeGen.h @@ -125,6 +125,7 @@ public: public: void InitTarget(); void FixValues(llvm::StructType* structType, llvm::SmallVector& values); + void FixIndexer(llvm::Value*& val); BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned); llvm::Type* GetLLVMType(BfTypeCode typeCode, bool& isSigned); BfIRTypeEntry& GetTypeEntry(int typeId);