From: Mircea Trofin Date: Wed, 15 Apr 2020 23:50:57 +0000 (-0700) Subject: [llvm][NFC][CallSite] Removed CallSite from some implementation details. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4213bc761a2cf4cfc62c459c8b5252a5dc29fc3a;p=platform%2Fupstream%2Fllvm.git [llvm][NFC][CallSite] Removed CallSite from some implementation details. Reviewers: craig.topper, dblaikie Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78256 --- diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp index b1de642..0d5a882 100644 --- 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 @@ using namespace llvm; #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; } @@ -166,21 +171,21 @@ int FunctionComparator::cmpRangeMetadata(const MDNode *L, return 0; } +// FIXME(CallSite): the parameters should be CallBase int FunctionComparator::cmpOperandBundlesSchema(const Instruction *L, const Instruction *R) const { - ImmutableCallSite LCS(L); - ImmutableCallSite RCS(R); + const CallBase *LCS = cast(L); + const CallBase *RCS = cast(R); - assert(LCS && RCS && "Must be calls or invokes!"); - assert(LCS.isCall() == RCS.isCall() && "Can't compare otherwise!"); + assert(LCS->getOpcode() == RCS->getOpcode() && "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 +366,12 @@ int FunctionComparator::cmpConstants(const Constant *L, 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 +566,8 @@ int FunctionComparator::cmpOperations(const Instruction *L, 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 +585,11 @@ int FunctionComparator::cmpOperations(const Instruction *L, } 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(L)) { + auto *CBR = 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 +632,8 @@ int FunctionComparator::cmpOperations(const Instruction *L, 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 +654,7 @@ int FunctionComparator::cmpOperations(const Instruction *L, 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 +691,8 @@ int FunctionComparator::cmpGEPs(const GEPOperator *GEPL, 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 +845,8 @@ int FunctionComparator::compareSignature() const { // 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 +913,7 @@ public: // 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 index 263a055..d67baf9 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -6084,9 +6084,9 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { 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 index da68d37..3c55df2 100644 --- 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 @@ void Mapper::remapInstruction(Instruction *I) { 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 @@ void Mapper::remapInstruction(Instruction *I) { 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 index b888605..2ae1da8 100644 --- 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 @@ namespace { 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) {