Skip to content

Commit

Permalink
Disable gcov instrumentation of functions using funclet-based excepti…
Browse files Browse the repository at this point in the history
…on handling

Summary: This patch fixes the crash from https://bugs.llvm.org/show_bug.cgi?id=34659 and https://bugs.llvm.org/show_bug.cgi?id=34833.

Reviewers: rnk, majnemer

Reviewed By: rnk, majnemer

Subscribers: majnemer, llvm-commits

Differential Revision: https://reviews.llvm.org/D38223

llvm-svn: 315677
  • Loading branch information
marco-c committed Oct 13, 2017
1 parent 1cd8cf3 commit 0dcf64a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -502,6 +503,13 @@ static bool functionHasLines(Function &F) {
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;
Expand Down Expand Up @@ -542,6 +550,8 @@ void GCOVProfiler::emitProfileNotes() {
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.
Expand Down Expand Up @@ -619,7 +629,10 @@ bool GCOVProfiler::emitProfileArcs() {
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();
Expand Down

0 comments on commit 0dcf64a

Please sign in to comment.