aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/BPF/BPFAdjustOpt.cpp')
-rw-r--r--llvm/lib/Target/BPF/BPFAdjustOpt.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/BPF/BPFAdjustOpt.cpp b/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
index 4ab0cbcc9247..afc47968bf65 100644
--- a/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
+++ b/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
@@ -12,7 +12,6 @@
#include "BPF.h"
#include "BPFCORE.h"
-#include "BPFTargetMachine.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsBPF.h"
@@ -126,10 +125,10 @@ bool BPFAdjustOptImpl::adjustICmpToBuiltin() {
Constant *Opcode =
ConstantInt::get(Type::getInt32Ty(BB.getContext()), Op);
- Function *Fn = Intrinsic::getDeclaration(
+ Function *Fn = Intrinsic::getOrInsertDeclaration(
M, Intrinsic::bpf_compare, {Op0->getType(), ConstOp1->getType()});
auto *NewInst = CallInst::Create(Fn, {Opcode, Op0, ConstOp1});
- NewInst->insertBefore(&I);
+ NewInst->insertBefore(I.getIterator());
Icmp->replaceAllUsesWith(NewInst);
Changed = true;
ToBeDeleted = Icmp;
@@ -223,7 +222,7 @@ bool BPFAdjustOptImpl::serializeICMPCrossBB(BasicBlock &BB) {
if (!BI || !BI->isConditional())
return false;
auto *Cond = dyn_cast<ICmpInst>(BI->getCondition());
- if (!Cond || B2->getFirstNonPHI() != Cond)
+ if (!Cond || &*B2->getFirstNonPHIIt() != Cond)
return false;
Value *B2Op0 = Cond->getOperand(0);
auto Cond2Op = Cond->getPredicate();