Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / StripDebugInfo.cpp
bloba65e55d5f6f4829f7fd109df612d0f31a9ee66d6
1 //===- StripDebugInfo.cpp -------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "StripDebugInfo.h"
10 #include "Delta.h"
11 #include "llvm/IR/DebugInfo.h"
12 #include "llvm/IR/Metadata.h"
14 using namespace llvm;
16 /// Removes all aliases aren't inside any of the
17 /// desired Chunks.
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().startswith("llvm.dbg.");
22 });
23 if (HasDebugInfo && !O.shouldKeep())
24 StripDebugInfo(Program);
27 void llvm::stripDebugInfoDeltaPass(TestRunner &Test) {
28 runDeltaPass(Test, stripDebugInfoImpl, "Stripping Debug Info");