diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp --- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp +++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp @@ -20,7 +20,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" @@ -52,22 +51,28 @@ #define DEBUG_TYPE "functioncomparator" int FunctionComparator::cmpNumbers(uint64_t L, uint64_t R) const { - if (L < R) return -1; - if (L > R) return 1; + if (L < R) + return -1; + if (L > R) + return 1; return 0; } int FunctionComparator::cmpOrderings(AtomicOrdering L, AtomicOrdering R) const { - if ((int)L < (int)R) return -1; - if ((int)L > (int)R) return 1; + if ((int)L < (int)R) + return -1; + if ((int)L > (int)R) + return 1; return 0; } int FunctionComparator::cmpAPInts(const APInt &L, const APInt &R) const { if (int Res = cmpNumbers(L.getBitWidth(), R.getBitWidth())) return Res; - if (L.ugt(R)) return 1; - if (R.ugt(L)) return -1; + if (L.ugt(R)) + return 1; + if (R.ugt(L)) + return -1; return 0; } @@ -168,19 +173,20 @@ int FunctionComparator::cmpOperandBundlesSchema(const Instruction *L, const Instruction *R) const { - ImmutableCallSite LCS(L); - ImmutableCallSite RCS(R); + const CallBase *LCS = dyn_cast(L); + const CallBase *RCS = dyn_cast(R); assert(LCS && RCS && "Must be calls or invokes!"); - assert(LCS.isCall() == RCS.isCall() && "Can't compare otherwise!"); + assert(isa(LCS) == isa(RCS) && + "Can't compare otherwise!"); if (int Res = - cmpNumbers(LCS.getNumOperandBundles(), RCS.getNumOperandBundles())) + cmpNumbers(LCS->getNumOperandBundles(), RCS->getNumOperandBundles())) return Res; - for (unsigned i = 0, e = LCS.getNumOperandBundles(); i != e; ++i) { - auto OBL = LCS.getOperandBundleAt(i); - auto OBR = RCS.getOperandBundleAt(i); + for (unsigned i = 0, e = LCS->getNumOperandBundles(); i != e; ++i) { + auto OBL = LCS->getOperandBundleAt(i); + auto OBR = RCS->getOperandBundleAt(i); if (int Res = OBL.getTagName().compare(OBR.getTagName())) return Res; @@ -361,12 +367,12 @@ if (LBA->getFunction() == RBA->getFunction()) { // They are BBs in the same function. Order by which comes first in the // BB order of the function. This order is deterministic. - Function* F = LBA->getFunction(); + Function *F = LBA->getFunction(); BasicBlock *LBB = LBA->getBasicBlock(); BasicBlock *RBB = RBA->getBasicBlock(); if (LBB == RBB) return 0; - for(BasicBlock &BB : F->getBasicBlockList()) { + for (BasicBlock &BB : F->getBasicBlockList()) { if (&BB == LBB) { assert(&BB != RBB); return -1; @@ -561,7 +567,8 @@ if (int Res = cmpNumbers(LI->getSyncScopeID(), cast(R)->getSyncScopeID())) return Res; - return cmpRangeMetadata(LI->getMetadata(LLVMContext::MD_range), + return cmpRangeMetadata( + LI->getMetadata(LLVMContext::MD_range), cast(R)->getMetadata(LLVMContext::MD_range)); } if (const StoreInst *SI = dyn_cast(L)) { @@ -579,11 +586,11 @@ } if (const CmpInst *CI = dyn_cast(L)) return cmpNumbers(CI->getPredicate(), cast(R)->getPredicate()); - if (auto CSL = CallSite(const_cast(L))) { - auto CSR = CallSite(const_cast(R)); - if (int Res = cmpNumbers(CSL.getCallingConv(), CSR.getCallingConv())) + if (auto *CBL = dyn_cast(const_cast(L))) { + auto *CBR = cast(const_cast(R)); + if (int Res = cmpNumbers(CBL->getCallingConv(), CBR->getCallingConv())) return Res; - if (int Res = cmpAttrs(CSL.getAttributes(), CSR.getAttributes())) + if (int Res = cmpAttrs(CBL->getAttributes(), CBR->getAttributes())) return Res; if (int Res = cmpOperandBundlesSchema(L, R)) return Res; @@ -626,8 +633,8 @@ if (int Res = cmpNumbers(CXI->isVolatile(), cast(R)->isVolatile())) return Res; - if (int Res = cmpNumbers(CXI->isWeak(), - cast(R)->isWeak())) + if (int Res = + cmpNumbers(CXI->isWeak(), cast(R)->isWeak())) return Res; if (int Res = cmpOrderings(CXI->getSuccessOrdering(), @@ -648,7 +655,7 @@ cast(R)->isVolatile())) return Res; if (int Res = cmpOrderings(RMWI->getOrdering(), - cast(R)->getOrdering())) + cast(R)->getOrdering())) return Res; return cmpNumbers(RMWI->getSyncScopeID(), cast(R)->getSyncScopeID()); @@ -685,8 +692,8 @@ if (GEPL->accumulateConstantOffset(DL, OffsetL) && GEPR->accumulateConstantOffset(DL, OffsetR)) return cmpAPInts(OffsetL, OffsetR); - if (int Res = cmpTypes(GEPL->getSourceElementType(), - GEPR->getSourceElementType())) + if (int Res = + cmpTypes(GEPL->getSourceElementType(), GEPR->getSourceElementType())) return Res; if (int Res = cmpNumbers(GEPL->getNumOperands(), GEPR->getNumOperands())) @@ -839,8 +846,8 @@ // Visit the arguments so that they get enumerated in the order they're // passed in. for (Function::const_arg_iterator ArgLI = FnL->arg_begin(), - ArgRI = FnR->arg_begin(), - ArgLE = FnL->arg_end(); + ArgRI = FnR->arg_begin(), + ArgLE = FnL->arg_end(); ArgLI != ArgLE; ++ArgLI, ++ArgRI) { if (cmpValues(&*ArgLI, &*ArgRI) != 0) llvm_unreachable("Arguments repeat!"); @@ -907,9 +914,7 @@ // Initialize to random constant, so the state isn't zero. HashAccumulator64() { Hash = 0x6acaa36bef8325c5ULL; } - void add(uint64_t V) { - Hash = hashing::detail::hash_16_bytes(Hash, V); - } + void add(uint64_t V) { Hash = hashing::detail::hash_16_bytes(Hash, V); } // No finishing is required, because the entire hash value is used. uint64_t getHash() { return Hash; } diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -6084,9 +6084,9 @@ SI->getPointerOperand() == I; // A call to null is undefined. - if (auto CS = CallSite(Use)) - return !NullPointerIsDefined(CS->getFunction()) && - CS.getCalledValue() == I; + if (auto *CB = dyn_cast(Use)) + return !NullPointerIsDefined(CB->getFunction()) && + CB->getCalledValue() == I; } return false; } diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -21,7 +21,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Argument.h" #include "llvm/IR/BasicBlock.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugInfoMetadata.h" @@ -888,17 +887,17 @@ return; // If the instruction's type is being remapped, do so now. - if (auto CS = CallSite(I)) { + if (auto *CB = dyn_cast(I)) { SmallVector Tys; - FunctionType *FTy = CS.getFunctionType(); + FunctionType *FTy = CB->getFunctionType(); Tys.reserve(FTy->getNumParams()); for (Type *Ty : FTy->params()) Tys.push_back(TypeMapper->remapType(Ty)); - CS.mutateFunctionType(FunctionType::get( + CB->mutateFunctionType(FunctionType::get( TypeMapper->remapType(I->getType()), Tys, FTy->isVarArg())); - LLVMContext &C = CS->getContext(); - AttributeList Attrs = CS.getAttributes(); + LLVMContext &C = CB->getContext(); + AttributeList Attrs = CB->getAttributes(); for (unsigned i = 0; i < Attrs.getNumAttrSets(); ++i) { if (Attrs.hasAttribute(i, Attribute::ByVal)) { Type *Ty = Attrs.getAttribute(i, Attribute::ByVal).getValueAsType(); @@ -910,7 +909,7 @@ C, i, Attribute::getWithByValType(C, TypeMapper->remapType(Ty))); } } - CS.setAttributes(Attrs); + CB->setAttributes(Attrs); return; } if (auto *AI = dyn_cast(I)) diff --git a/llvm/tools/opt/AnalysisWrappers.cpp b/llvm/tools/opt/AnalysisWrappers.cpp --- a/llvm/tools/opt/AnalysisWrappers.cpp +++ b/llvm/tools/opt/AnalysisWrappers.cpp @@ -17,7 +17,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/CallGraph.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/raw_ostream.h" @@ -40,11 +39,11 @@ Instruction *UI = dyn_cast(U); if (!UI) continue; - CallSite CS(cast(UI)); - if (!CS) continue; + CallBase *CB = (dyn_cast(UI)); + if (!CB) + continue; - for (CallSite::arg_iterator AI = CS.arg_begin(), - E = CS.arg_end(); AI != E; ++AI) { + for (auto AI = CB->arg_begin(), E = CB->arg_end(); AI != E; ++AI) { if (!isa(*AI)) continue; if (!PrintedFn) {