From 144c5a6c154b3d639709c59892a41139aadc5032 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Fri, 12 Feb 2016 21:01:31 +0000 Subject: [PATCH] Add convergent property to CodeMetrics. Summary: No functional changes. Reviewers: jingyue, arsenm Subscribers: arsenm, llvm-commits Differential Revision: http://reviews.llvm.org/D17126 llvm-svn: 260728 --- llvm/include/llvm/Analysis/CodeMetrics.h | 3 +++ llvm/lib/Analysis/CodeMetrics.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Analysis/CodeMetrics.h b/llvm/include/llvm/Analysis/CodeMetrics.h index 5f6b0586c240..f512aca57865 100644 --- a/llvm/include/llvm/Analysis/CodeMetrics.h +++ b/llvm/include/llvm/Analysis/CodeMetrics.h @@ -53,6 +53,9 @@ struct CodeMetrics { /// 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; diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp index 4090b4cd752b..035717aa6138 100644 --- a/llvm/lib/Analysis/CodeMetrics.cpp +++ b/llvm/lib/Analysis/CodeMetrics.cpp @@ -152,9 +152,12 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, 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())