From c9fe908dea7774d5600c7e3f83ff272c5a74cab3 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 18 Jul 2017 15:42:59 +0000 Subject: [PATCH] [TRE] Simplify canTRE() a bit using all_of(). NFCI. This has a ~11 years old FIXME, which may not be true today. We might consider removing this code altogether. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308319 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/TailRecursionElimination.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 9397b87cdf5..90c5c243f46 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -68,6 +68,7 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Function.h" +#include "llvm/IR/InstIterator.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" @@ -90,16 +91,10 @@ STATISTIC(NumAccumAdded, "Number of accumulators introduced"); /// If it contains any dynamic allocas, returns false. static bool canTRE(Function &F) { // Because of PR962, we don't TRE dynamic allocas. - for (auto &BB : F) { - for (auto &I : BB) { - if (AllocaInst *AI = dyn_cast(&I)) { - if (!AI->isStaticAlloca()) - return false; - } - } - } - - return true; + return llvm::all_of(instructions(F), [](Instruction &I) { + auto *AI = dyn_cast(&I); + return !AI || AI->isStaticAlloca(); + }); } namespace { -- 2.11.0