2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-reduce/remove-bbs-unreachable.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; unreachable blocks.
;
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=basic-blocks --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
; RUN: cat %t | FileCheck %s
; RUN: FileCheck %s < %t

; CHECK-INTERESTINGNESS: test

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-reduce/remove-bbs.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; Test that llvm-reduce can remove uninteresting Basic Blocks, and remove them from instructions (i.e. SwitchInst, BranchInst and IndirectBrInst)
; Note: if an uninteresting BB is the default case for a switch, the instruction is removed altogether (since the default case cannot be replaced)
;
; RUN: llvm-reduce --delta-passes=basic-blocks --test %python --test-arg %p/Inputs/remove-bbs.py %s -o %t
; RUN: cat %t | FileCheck -implicit-check-not=uninteresting %s
; RUN: llvm-reduce -abort-on-invalid-reduction --delta-passes=basic-blocks --test %python --test-arg %p/Inputs/remove-bbs.py %s -o %t
; RUN: FileCheck -implicit-check-not=uninteresting %s < %t

define void @main() {
interesting:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-reduce/remove-call-site-attributes.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; Test that llvm-reduce can remove uninteresting operand bundles from calls.
;
; RUN: llvm-reduce --delta-passes=operand-bundles,attributes --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
; RUN: llvm-reduce -abort-on-invalid-reduction --delta-passes=operand-bundles,attributes --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
; RUN: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s

; CHECK-ALL: declare i32 @f1(i32, i32)
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/DeltaManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- DeltaManager.h - Runs Delta Passes to reduce Input -----------------===//
//===- DeltaManager.h - Runs Delta Passes to reduce Input -------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/ReducerWorkItem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReducerWorkItem.h - Wrapper for Module and MachineFunction ---------===//
//===- ReducerWorkItem.h - Wrapper for Module -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/Delta.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Delta.h - Delta Debugging Algorithm Implementation -----------------===//
//===- Delta.h - Delta Debugging Algorithm Implementation -------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceAliases.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceAliases.h - Specialized Delta Pass ---------------------------===//
//===- ReduceAliases.h - Specialized Delta Pass -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceArguments.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceArguments.h - Specialized Delta Pass -------------------------===//
//===- ReduceArguments.h - Specialized Delta Pass ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceAttributes.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceAttributes.h - Specialized Delta Pass ------------------------===//
//===- ReduceAttributes.h - Specialized Delta Pass --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceArguments.h - Specialized Delta Pass -------------------------===//
//===- ReduceArguments.h - Specialized Delta Pass ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceFunctionBodies.h - Specialized Delta Pass --------------------===//
//===- ReduceFunctionBodies.h - Specialized Delta Pass ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceFunctions.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceFunctions.h - Specialized Delta Pass -------------------------===//
//===- ReduceFunctions.h - Specialized Delta Pass ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceGlobalObjects.h ----------------------------------------------===//
//===- ReduceGlobalObjects.h ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceGlobalValues.h - Specialized Delta Pass ----------------------===//
//===- ReduceGlobalValues.h - Specialized Delta Pass ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- reduceGlobalsInitializersDeltaPass.h - Specialized Delta Pass ------===//
//===- ReduceGlobalVarInitializers.h ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceGlobalVars.h - Specialized Delta Pass ------------------------===//
//===- ReduceGlobalVars.h - Specialized Delta Pass --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceInstructionFlagsMIR.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceInstructionFlagsMIR.h - Specialized Delta Pass --------------===//
//===- ReduceInstructionFlagsMIR.h -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceInstructions.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceArguments.h - Specialized Delta Pass -------------------------===//
//===- ReduceInstructions.h -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceInstructionsMIR.h - Specialized Delta Pass ------------------===//
//===- ReduceInstructionsMIR.h - Specialized Delta Pass --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceMetadata.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceMetadata.h - Specialized Delta Pass --------------------------===//
//===- ReduceMetadata.h - Specialized Delta Pass ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceModuleData.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceModuleData.h --------------------------------------------===//
//===- ReduceModuleData.h ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceOperandBundles.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceOperandBundes.h - Specialized Delta Pass ---------------------===//
//===- ReduceOperandBundes.h ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
11 changes: 11 additions & 0 deletions llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ extractOperandsFromModule(Oracle &O, Module &Program,
function_ref<Value *(Use &)> ReduceValue) {
for (auto &F : Program.functions()) {
for (auto &I : instructions(&F)) {
if (PHINode *Phi = dyn_cast<PHINode>(&I)) {
for (auto &Op : Phi->incoming_values()) {
if (!O.shouldKeep()) {
if (Value *Reduced = ReduceValue(Op))
Phi->setIncomingValueForBlock(Phi->getIncomingBlock(Op), Reduced);
}
}

continue;
}

for (auto &Op : I.operands()) {
if (!O.shouldKeep()) {
if (Value *Reduced = ReduceValue(Op))
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceOperands.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===----------------------------------------------------------------------===//
//===------------------------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
8 changes: 6 additions & 2 deletions llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ static void extractOperandsFromModule(Oracle &O, Module &Program) {
}
});

for (std::pair<Use *, Value *> P : Replacements)
P.first->set(P.second);
for (std::pair<Use *, Value *> P : Replacements) {
if (PHINode *Phi = dyn_cast<PHINode>(P.first->getUser()))
Phi->setIncomingValueForBlock(Phi->getIncomingBlock(*P.first), P.second);
else
P.first->set(P.second);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===----------------------------------------------------------------------===//
//===------------------------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===----------------------------------------------------------------------===//
//===------------------------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceSpecialGlobals.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceSpecialGlobals.h - Specialized Delta Pass --------------------===//
//===- ReduceSpecialGlobals.h - Specialized Delta Pass ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ReduceUsingSimplifyCFG.h - Specialized Delta Pass ------------------===//
//===- ReduceUsingSimplifyCFG.h - Specialized Delta Pass --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/RunIRPasses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- RunIRPasses.h ------------------------------------------------------===//
//===- RunIRPasses.h --------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-reduce/deltas/Utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Utils.h - llvm-reduce utility functions ----------------------------===//
//===- Utils.h - llvm-reduce utility functions ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down