| 1 |
//===- ReduceDbgRecords.cpp - Specialized Delta Pass ----------------------===// |
| 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 |
// This file implements a function which calls the Generic Delta pass in order |
| 10 |
// to reduce uninteresting DbgVariableRecords from defined functions. |
| 11 |
// |
| 12 |
// DbgVariableRecords store variable-location debug-info and are attached to |
| 13 |
// instructions. This information used to be represented by intrinsics such as |
| 14 |
// dbg.value, and would naturally get reduced by llvm-reduce like any other |
| 15 |
// instruction. As DbgVariableRecords get stored elsewhere, they need to be |
| 16 |
// enumerated and eliminated like any other data structure in LLVM. |
| 17 |
// |
| 18 |
//===----------------------------------------------------------------------===// |
| 19 |
|
| 20 |
#include "ReduceDbgRecords.h" |
| 21 |
#include "llvm/ADT/STLExtras.h" |
| 22 |
#include "llvm/IR/BasicBlock.h" |
| 23 |
#include "llvm/IR/DebugProgramInstruction.h" |
| 24 |
|
| 25 |
using namespace llvm; |
| 26 |
|
| 27 |
void llvm::reduceDbgRecordDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) { |
| 28 |
Module &M = WorkItem.getModule(); |
| 29 |
|
| 30 |
for (auto &F : M) |
| 31 |
for (auto &BB : F) |
| 32 |
for (auto &I : BB) |
| 33 |
for (DbgRecord &DR : llvm::make_early_inc_range(I.getDbgRecordRange())) |
| 34 |
if (!O.shouldKeep()) |
| 35 |
DR.eraseFromParent(); |
| 36 |
} |