diff options
-rw-r--r-- | backend/src/llvm/llvm_passes.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp index 7187caa6..1b403898 100644 --- a/backend/src/llvm/llvm_passes.cpp +++ b/backend/src/llvm/llvm_passes.cpp @@ -358,14 +358,16 @@ namespace gbe CompTy = dyn_cast<CompositeType>(CompTy->getTypeAtIndex(TypeIndex)); } - //insert addition of new offset before GEPInst - Constant* newConstOffset = - ConstantInt::get(IntegerType::get(GEPInst->getContext(), - ptrSize), - constantOffset); - currentAddrInst = - BinaryOperator::Create(Instruction::Add, currentAddrInst, - newConstOffset, "", GEPInst); + //insert addition of new offset before GEPInst when it is not zero + if (constantOffset != 0) { + Constant* newConstOffset = + ConstantInt::get(IntegerType::get(GEPInst->getContext(), + ptrSize), + constantOffset); + currentAddrInst = + BinaryOperator::Create(Instruction::Add, currentAddrInst, + newConstOffset, "", GEPInst); + } //convert offset to ptr type (nop) IntToPtrInst* intToPtrInst = |