[PATCH] D38223: Disable gcov instrumentation of functions using funclet-based exception handling

Marco Castelluccio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 03:41:46 PDT 2017


marco-c updated this revision to Diff 118768.
marco-c added a comment.

Simply moved the isUsingFuncletBasedEH check before setting Result, otherwise it could be set to true even when it wasn't supposed to.


https://reviews.llvm.org/D38223

Files:
  lib/Transforms/Instrumentation/GCOVProfiling.cpp


Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp
===================================================================
--- lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -21,6 +21,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/UniqueVector.h"
+#include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/IRBuilder.h"
@@ -502,6 +503,13 @@
   return false;
 }
 
+static bool isUsingFuncletBasedEH(Function &F) {
+  if (!F.hasPersonalityFn()) return false;
+
+  EHPersonality Personality = classifyEHPersonality(F.getPersonalityFn());
+  return isFuncletEHPersonality(Personality);
+}
+
 static bool shouldKeepInEntry(BasicBlock::iterator It) {
 	if (isa<AllocaInst>(*It)) return true;
 	if (isa<DbgInfoIntrinsic>(*It)) return true;
@@ -542,6 +550,8 @@
       DISubprogram *SP = F.getSubprogram();
       if (!SP) continue;
       if (!functionHasLines(F)) continue;
+      // TODO: Functions using funclet-based EH are currently not supported.
+      if (isUsingFuncletBasedEH(F)) continue;
 
       // gcov expects every function to start with an entry block that has a
       // single successor, so split the entry block to make sure of that.
@@ -619,7 +629,10 @@
       DISubprogram *SP = F.getSubprogram();
       if (!SP) continue;
       if (!functionHasLines(F)) continue;
+      // TODO: Functions using funclet-based EH are currently not supported.
+      if (isUsingFuncletBasedEH(F)) continue;
       if (!Result) Result = true;
+
       unsigned Edges = 0;
       for (auto &BB : F) {
         TerminatorInst *TI = BB.getTerminator();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38223.118768.patch
Type: text/x-patch
Size: 1721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/5bf28c77/attachment.bin>


More information about the llvm-commits mailing list