@@ -1443,17 +1443,8 @@ void LifetimeCheckPass::checkPointerDeref(mlir::Value addr, mlir::Location loc,
14431443 emitPsetRemark ();
14441444}
14451445
1446- static FuncOp getCalleeFromSymbol (ModuleOp mod, llvm::StringRef name) {
1447- auto global = mlir::SymbolTable::lookupSymbolIn (mod, name);
1448- assert (global && " expected to find symbol for function" );
1449- return dyn_cast<FuncOp>(global);
1450- }
1451-
14521446static const ASTCXXMethodDeclInterface getMethod (ModuleOp mod, CallOp callOp) {
1453- if (!callOp.getCallee ())
1454- return nullptr ;
1455- llvm::StringRef name = *callOp.getCallee ();
1456- auto method = getCalleeFromSymbol (mod, name);
1447+ auto method = callOp.getDirectCallee (mod);
14571448 if (!method || method.getBuiltin ())
14581449 return nullptr ;
14591450 return dyn_cast<ASTCXXMethodDeclInterface>(method.getAstAttr ());
@@ -1756,12 +1747,10 @@ bool LifetimeCheckPass::isTaskType(mlir::Value taskVal) {
17561747}
17571748
17581749void LifetimeCheckPass::trackCallToCoroutine (CallOp callOp) {
1759- if (auto fnName = callOp.getCallee ()) {
1760- auto calleeFuncOp = getCalleeFromSymbol (theModule, *fnName);
1761- if (calleeFuncOp &&
1762- (calleeFuncOp.getCoroutine () ||
1763- (calleeFuncOp.isDeclaration () && callOp->getNumResults () > 0 &&
1764- isTaskType (callOp->getResult (0 ))))) {
1750+ if (auto calleeFuncOp = callOp.getDirectCallee (theModule)) {
1751+ if (calleeFuncOp.getCoroutine () ||
1752+ (calleeFuncOp.isDeclaration () && callOp->getNumResults () > 0 &&
1753+ isTaskType (callOp->getResult (0 )))) {
17651754 currScope->localTempTasks .insert (callOp->getResult (0 ));
17661755 }
17671756 return ;
@@ -1792,13 +1781,11 @@ void LifetimeCheckPass::checkCall(CallOp callOp) {
17921781
17931782 // From this point on only owner and pointer class methods handling,
17941783 // starting from special methods.
1795- if (auto fnName = callOp.getCallee ()) {
1796- auto calleeFuncOp = getCalleeFromSymbol (theModule, *fnName);
1797- if (calleeFuncOp && calleeFuncOp.getCxxSpecialMember ())
1798- if (auto cxxCtor =
1799- dyn_cast<cir::CXXCtorAttr>(*calleeFuncOp.getCxxSpecialMember ()))
1800- return checkCtor (callOp, cxxCtor);
1801- }
1784+ auto calleeFuncOp = callOp.getDirectCallee (theModule);
1785+ if (calleeFuncOp && calleeFuncOp.getCxxSpecialMember ())
1786+ if (auto cxxCtor =
1787+ dyn_cast<cir::CXXCtorAttr>(*calleeFuncOp.getCxxSpecialMember ()))
1788+ return checkCtor (callOp, cxxCtor);
18021789 if (methodDecl.isMoveAssignmentOperator ())
18031790 return checkMoveAssignment (callOp, methodDecl);
18041791 if (methodDecl.isCopyAssignmentOperator ())
0 commit comments