1 //===- StripDebugInfo.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "StripDebugInfo.h"
11 #include "llvm/IR/DebugInfo.h"
12 #include "llvm/IR/Metadata.h"
16 /// Removes all aliases aren't inside any of the
18 static void stripDebugInfoImpl(Oracle
&O
, ReducerWorkItem
&WorkItem
) {
19 Module
&Program
= WorkItem
.getModule();
20 bool HasDebugInfo
= any_of(Program
.named_metadata(), [](NamedMDNode
&NMD
) {
21 return NMD
.getName().starts_with("llvm.dbg.");
23 if (HasDebugInfo
&& !O
.shouldKeep())
24 StripDebugInfo(Program
);
27 void llvm::stripDebugInfoDeltaPass(TestRunner
&Test
) {
28 runDeltaPass(Test
, stripDebugInfoImpl
, "Stripping Debug Info");