summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-10-17 20:05:35 +0000
committerDavide Italiano <davide@freebsd.org>2016-10-17 20:05:35 +0000
commit84bd58e915db2495ac91965f73b31e4f7d5244f4 (patch)
treef141c9defceebfd711483cfe3f5c3bc68a758c5a /llvm/lib
parent119a998ae3895ff360fc2ddb32f387927dbb2a33 (diff)
downloadbcm5719-llvm-84bd58e915db2495ac91965f73b31e4f7d5244f4.tar.gz
bcm5719-llvm-84bd58e915db2495ac91965f73b31e4f7d5244f4.zip
[opt] Strip coverage if debug info is not present.
If -coverage is passed, but -g is not, clang populates the PassManager pipeline with StripSymbols(debugOnly = true). The stripSymbol pass therefore scans the list of named metadata, drops !llvm.dbg.cu, but leaves !llvm.gcov and !0 (the compileUnit MD) around. The verifier runs, and finds out that there's a CU not listed in !llvm.dbg.cu (as it was previously dropped) -> crash. When we strip debug info, so, check if there's coverage data, and strip it as well, in order to avoid pending metadata left around. Differential Revision: https://reviews.llvm.org/D25689 llvm-svn: 284418
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 80f97b3e049..be00387682f 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -272,7 +272,11 @@ bool llvm::StripDebugInfo(Module &M) {
NME = M.named_metadata_end(); NMI != NME;) {
NamedMDNode *NMD = &*NMI;
++NMI;
- if (NMD->getName().startswith("llvm.dbg.")) {
+
+ // We're stripping debug info, and without them, coverage information
+ // doesn't quite make sense.
+ if (NMD->getName().startswith("llvm.dbg.") ||
+ NMD->getName() == "llvm.gcov") {
NMD->eraseFromParent();
Changed = true;
}
OpenPOWER on IntegriCloud