From 388c85b18f35462645a6826b160a3fa091418997 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 3 Sep 2015 20:18:29 +0000 Subject: [PATCH] [sancov] Disable sanitizer coverage on functions using SEH Splitting basic blocks really messes up WinEHPrepare. We can remove this change when SEH uses the new EH IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246799 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 7 +++++++ .../SanitizerCoverage/{localescape.ll => seh.ll} | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-) rename test/Instrumentation/SanitizerCoverage/{localescape.ll => seh.ll} (92%) diff --git a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 3bcb8de1c4f..b021f31e652 100644 --- a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -31,6 +31,7 @@ #include "llvm/Transforms/Instrumentation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Analysis/LibCallSemantics.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DebugInfo.h" @@ -290,6 +291,12 @@ bool SanitizerCoverageModule::runOnFunction(Function &F) { if (F.empty()) return false; if (F.getName().find(".module_ctor") != std::string::npos) return false; // Should not instrument sanitizer init functions. + // Don't instrument functions using SEH for now. Splitting basic blocks like + // we do for coverage breaks WinEHPrepare. + // FIXME: Remove this when SEH no longer uses landingpad pattern matching. + if (F.hasPersonalityFn() && + isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) + return false; if (Options.CoverageType >= SanitizerCoverageOptions::SCK_Edge) SplitAllCriticalEdges(F); SmallVector IndirCalls; diff --git a/test/Instrumentation/SanitizerCoverage/localescape.ll b/test/Instrumentation/SanitizerCoverage/seh.ll similarity index 92% rename from test/Instrumentation/SanitizerCoverage/localescape.ll rename to test/Instrumentation/SanitizerCoverage/seh.ll index eff47c64f09..ce18334ed20 100644 --- a/test/Instrumentation/SanitizerCoverage/localescape.ll +++ b/test/Instrumentation/SanitizerCoverage/seh.ll @@ -45,14 +45,12 @@ eh.resume: ; preds = %lpad resume { i8*, i32 } %1 } -; Check that the alloca remains static and the localescape call remains in the -; entry block. +; Check that we don't do any instrumentation. ; CHECK-LABEL: define i32 @main() -; CHECK-NOT: br {{.*}}label -; CHECK: %__exception_code = alloca i32, align 4 -; CHECK-NOT: br {{.*}}label -; CHECK: call void (...) @llvm.localescape(i32* nonnull %__exception_code) +; CHECK-NOT: load atomic i32, i32* {{.*}} monotonic, align 4, !nosanitize +; CHECK-NOT: call void @__sanitizer_cov +; CHECK: ret i32 ; Function Attrs: nounwind define internal i32 @"\01?filt$0@0@main@@"() #1 { -- 2.34.1