Index: include/llvm/Analysis/CodeMetrics.h =================================================================== --- include/llvm/Analysis/CodeMetrics.h +++ include/llvm/Analysis/CodeMetrics.h @@ -53,6 +53,9 @@ /// one or more 'noduplicate' instructions. bool notDuplicatable = false; + /// \brief True if this function contains a call to a convergent function. + bool convergent = false; + /// \brief True if this function calls alloca (in the C sense). bool usesDynamicAlloca = false; Index: lib/Analysis/CodeMetrics.cpp =================================================================== --- lib/Analysis/CodeMetrics.cpp +++ lib/Analysis/CodeMetrics.cpp @@ -152,9 +152,12 @@ if (II->getType()->isTokenTy() && II->isUsedOutsideOfBlock(BB)) notDuplicatable = true; - if (const CallInst *CI = dyn_cast(II)) + if (const CallInst *CI = dyn_cast(II)) { if (CI->cannotDuplicate()) notDuplicatable = true; + if (CI->isConvergent()) + convergent = true; + } if (const InvokeInst *InvI = dyn_cast(II)) if (InvI->cannotDuplicate())