1 //===- SimplifyInstructions.cpp - Specialized Delta Pass ------------------===//
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 // This file implements a function which calls the Generic Delta pass in order
10 // to simplify Instructions in defined functions.
12 //===----------------------------------------------------------------------===//
14 #include "SimplifyInstructions.h"
15 #include "llvm/Analysis/InstructionSimplify.h"
16 #include "llvm/IR/Constants.h"
20 /// Calls simplifyInstruction in each instruction in functions, and replaces
22 static void extractInstrFromModule(Oracle
&O
, ReducerWorkItem
&WorkItem
) {
23 std::vector
<Instruction
*> InstsToDelete
;
25 Module
&Program
= WorkItem
.getModule();
26 const DataLayout
&DL
= Program
.getDataLayout();
28 std::vector
<Instruction
*> InstToDelete
;
29 for (auto &F
: Program
) {
31 for (auto &Inst
: BB
) {
33 SimplifyQuery
Q(DL
, &Inst
);
34 if (Value
*Simplified
= simplifyInstruction(&Inst
, Q
)) {
37 Inst
.replaceAllUsesWith(Simplified
);
38 InstToDelete
.push_back(&Inst
);
44 for (Instruction
*I
: InstToDelete
)
48 void llvm::simplifyInstructionsDeltaPass(TestRunner
&Test
) {
49 runDeltaPass(Test
, extractInstrFromModule
, "Simplifying Instructions");