| 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 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "StripDebugInfo.h" |
| 10 |
#include "Delta.h" |
| 11 |
#include "llvm/IR/DebugInfo.h" |
| 12 |
#include "llvm/IR/Metadata.h" |
| 13 |
|
| 14 |
using namespace llvm; |
| 15 |
|
| 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); |
| 25 |
} |
| 26 |
|
| 27 |
void llvm::stripDebugInfoDeltaPass(TestRunner &Test) { |
| 28 |
runDeltaPass(Test, stripDebugInfoImpl, "Stripping Debug Info"); |
| 29 |
} |