diff options
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp index 0930206c0ae9..6fe7688224d3 100644 --- a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp +++ b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp @@ -45,7 +45,6 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Type.h" #include "llvm/IR/Use.h" #include "llvm/IR/User.h" @@ -100,8 +99,8 @@ class PPCBoolRetToInt : public FunctionPass { Value *Zero = Constant::getNullValue(IntTy); PHINode *Q = PHINode::Create(IntTy, P->getNumIncomingValues(), P->getName(), P->getIterator()); - for (unsigned i = 0; i < P->getNumOperands(); ++i) - Q->addIncoming(Zero, P->getIncomingBlock(i)); + for (unsigned I = 0; I < P->getNumOperands(); ++I) + Q->addIncoming(Zero, P->getIncomingBlock(I)); return Q; } @@ -117,7 +116,7 @@ class PPCBoolRetToInt : public FunctionPass { // A PHINode is Promotable if: // 1. Its type is i1 AND - // 2. All of its uses are ReturnInt, CallInst, PHINode, or DbgInfoIntrinsic + // 2. All of its uses are ReturnInt, CallInst, or PHINode // AND // 3. All of its operands are Constant or Argument or // CallInst or PHINode AND @@ -136,8 +135,7 @@ class PPCBoolRetToInt : public FunctionPass { for (const PHINode *P : Promotable) { // Condition 2 and 3 auto IsValidUser = [] (const Value *V) -> bool { - return isa<ReturnInst>(V) || isa<CallInst>(V) || isa<PHINode>(V) || - isa<DbgInfoIntrinsic>(V); + return isa<ReturnInst>(V) || isa<CallInst>(V) || isa<PHINode>(V); }; auto IsValidOperand = [] (const Value *V) -> bool { return isa<Constant>(V) || isa<Argument>(V) || isa<CallInst>(V) || @@ -178,9 +176,7 @@ class PPCBoolRetToInt : public FunctionPass { public: static char ID; - PPCBoolRetToInt() : FunctionPass(ID) { - initializePPCBoolRetToIntPass(*PassRegistry::getPassRegistry()); - } + PPCBoolRetToInt() : FunctionPass(ID) {} bool runOnFunction(Function &F) override { if (skipFunction(F)) @@ -241,9 +237,11 @@ class PPCBoolRetToInt : public FunctionPass { ++NumBoolCallPromotion; ++NumBoolToIntPromotion; - for (Value *V : Defs) - if (!BoolToIntMap.count(V)) - BoolToIntMap[V] = translate(V); + for (Value *V : Defs) { + auto [It, Inserted] = BoolToIntMap.try_emplace(V); + if (Inserted) + It->second = translate(V); + } // Replace the operands of the translated instructions. They were set to // zero in the translate function. @@ -254,8 +252,8 @@ class PPCBoolRetToInt : public FunctionPass { // Operands of CallInst/Constant are skipped because they may not be Bool // type. For CallInst, their positions are defined by ABI. if (First && !isa<CallInst>(First) && !isa<Constant>(First)) - for (unsigned i = 0; i < First->getNumOperands(); ++i) - Second->setOperand(i, BoolToIntMap[First->getOperand(i)]); + for (unsigned I = 0; I < First->getNumOperands(); ++I) + Second->setOperand(I, BoolToIntMap[First->getOperand(I)]); } Value *IntRetVal = BoolToIntMap[U]; |
