From b60736ec1405bb0a8dd40989f67ef4c93da068ab Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 16 Feb 2021 21:13:02 +0100 Subject: Vendor import of llvm-project main 8e464dd76bef, the last commit before the upstream release/12.x branch was created. --- llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp | 56 ++----------------------- 1 file changed, 3 insertions(+), 53 deletions(-) (limited to 'llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp') diff --git a/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp b/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp index 83fc16ed98fc..6528154ab0e2 100644 --- a/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp +++ b/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/IntrinsicsXCore.h" #include "llvm/IR/Module.h" #include "llvm/IR/NoFolder.h" +#include "llvm/IR/ReplaceConstant.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" @@ -74,61 +75,10 @@ createLoweredInitializer(ArrayType *NewType, Constant *OriginalInitializer) { return ConstantArray::get(NewType, Elements); } -static Instruction * -createReplacementInstr(ConstantExpr *CE, Instruction *Instr) { - IRBuilder Builder(Instr); - unsigned OpCode = CE->getOpcode(); - switch (OpCode) { - case Instruction::GetElementPtr: { - SmallVector CEOpVec(CE->op_begin(), CE->op_end()); - ArrayRef CEOps(CEOpVec); - return dyn_cast(Builder.CreateInBoundsGEP( - cast(CE)->getSourceElementType(), CEOps[0], - CEOps.slice(1))); - } - case Instruction::Add: - case Instruction::Sub: - case Instruction::Mul: - case Instruction::UDiv: - case Instruction::SDiv: - case Instruction::FDiv: - case Instruction::URem: - case Instruction::SRem: - case Instruction::FRem: - case Instruction::Shl: - case Instruction::LShr: - case Instruction::AShr: - case Instruction::And: - case Instruction::Or: - case Instruction::Xor: - return dyn_cast( - Builder.CreateBinOp((Instruction::BinaryOps)OpCode, - CE->getOperand(0), CE->getOperand(1), - CE->getName())); - case Instruction::Trunc: - case Instruction::ZExt: - case Instruction::SExt: - case Instruction::FPToUI: - case Instruction::FPToSI: - case Instruction::UIToFP: - case Instruction::SIToFP: - case Instruction::FPTrunc: - case Instruction::FPExt: - case Instruction::PtrToInt: - case Instruction::IntToPtr: - case Instruction::BitCast: - return dyn_cast( - Builder.CreateCast((Instruction::CastOps)OpCode, - CE->getOperand(0), CE->getType(), - CE->getName())); - default: - llvm_unreachable("Unhandled constant expression!\n"); - } -} static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) { do { - SmallVector WUsers(CE->user_begin(), CE->user_end()); + SmallVector WUsers(CE->users()); llvm::sort(WUsers); WUsers.erase(std::unique(WUsers.begin(), WUsers.end()), WUsers.end()); while (!WUsers.empty()) @@ -201,7 +151,7 @@ bool XCoreLowerThreadLocal::lowerGlobal(GlobalVariable *GV) { GV->isExternallyInitialized()); // Update uses. - SmallVector Users(GV->user_begin(), GV->user_end()); + SmallVector Users(GV->users()); for (unsigned I = 0, E = Users.size(); I != E; ++I) { User *U = Users[I]; Instruction *Inst = cast(U); -- cgit v1.2.3