From 2628f9f61b4c2c0dda8b830ceae504d78f8acf69 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sun, 14 Jul 2019 23:32:35 +0200 Subject: fix crash with case insensitive compare functions (str(n)casecmp()) --- llvm_mode/compare-transform-pass.so.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'llvm_mode/compare-transform-pass.so.cc') diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc index 95435db7..d0dbe8ec 100644 --- a/llvm_mode/compare-transform-pass.so.cc +++ b/llvm_mode/compare-transform-pass.so.cc @@ -257,6 +257,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const std::vector args; args.push_back(load); load = IRB.CreateCall(tolowerFn, args, "tmp"); + load = IRB.CreateTrunc(load, Int8Ty); } Value *isub; if (HasStr1) @@ -272,14 +273,9 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const next_bb = BasicBlock::Create(C, "cmp_added", end_bb->getParent(), end_bb); BranchInst::Create(end_bb, next_bb); -#if LLVM_VERSION_MAJOR < 8 - TerminatorInst *term = cur_bb->getTerminator(); -#else - Instruction *term = cur_bb->getTerminator(); -#endif Value *icmp = IRB.CreateICmpEQ(isub, ConstantInt::get(Int8Ty, 0)); IRB.CreateCondBr(icmp, next_bb, end_bb); - term->eraseFromParent(); + cur_bb->getTerminator()->eraseFromParent(); } else { //IRB.CreateBr(end_bb); } -- cgit 1.4.1