[llvm] r343663 - Improve static analysis of cold basic blocks
Aditya K via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 4 10:58:32 PDT 2018
> Hm, it should be reasonable to add a test for this as well.
Agreed, I have a testcase, I'll upload soon.
-Aditya
________________________________
From: vsk at apple.com <vsk at apple.com> on behalf of Vedant Kumar <vsk at apple.com>
Sent: Wednesday, October 3, 2018 7:38 PM
To: Aditya Kumar
Cc: Vedant Kumar via llvm-commits
Subject: Re: [llvm] r343663 - Improve static analysis of cold basic blocks
Hm, it should be reasonable to add a test for this as well.
vedant
On Oct 3, 2018, at 6:36 PM, Vedant Kumar via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
Hi Aditya,
Thanks for working on this :).
On Oct 2, 2018, at 11:21 PM, Aditya Kumar via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
Author: hiraditya
Date: Tue Oct 2 23:21:05 2018
New Revision: 343663
URL: http://llvm.org/viewvc/llvm-project?rev=343663&view=rev
Log:
Improve static analysis of cold basic blocks
Differential Revision: https://reviews.llvm.org/D52704
Reviewers: sebpop, tejohnson, brzycki, SirishP
Reviewed By: sebpop
Modified:
llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
Modified: llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp?rev=343663&r1=343662&r2=343663&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp Tue Oct 2 23:21:05 2018
@@ -111,6 +111,18 @@ bool blockEndsInUnreachable(const BasicB
return succ_empty(&BB);
}
+static bool exceptionHandlingFunctions(const CallInst *CI) {
Could you use verb phrases for function names (see https://www.llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly)?
+ auto F = CI->getCalledFunction();
+ if (!F)
+ return false;
+ auto FName = F->getName();
+ return FName == "__cxa_begin_catch" ||
+ FName == "__cxa_free_exception" ||
+ FName == "__cxa_allocate_exception" ||
+ FName == "__cxa_begin_catch" ||
+ FName == "__cxa_end_catch”;
Given how hot this might be, would it make sense to return early if, say, the name doesn’t begin with “__”? Ideally we’d use some sort of off-the-shelf multi-string matching function, but absent that..
thanks,
vedant
+}
+
static
bool unlikelyExecuted(const BasicBlock &BB) {
if (blockEndsInUnreachable(BB))
@@ -122,7 +134,8 @@ bool unlikelyExecuted(const BasicBlock &
if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
// The block is cold if it calls functions tagged as cold or noreturn.
if (CI->hasFnAttr(Attribute::Cold) ||
- CI->hasFnAttr(Attribute::NoReturn))
+ CI->hasFnAttr(Attribute::NoReturn) ||
+ exceptionHandlingFunctions(CI))
return true;
// Assume that inline assembly is hot code.
_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181004/34de3665/attachment.html>
More information about the llvm-commits
mailing list