diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 9a47130c7b3a..f2af475c0424 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -75,6 +75,11 @@ void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs, if (!BlocksToExtract.count(PN->getIncomingBlock(i)) && (isa(V) || isa(V))) inputs.push_back(V); + else if (Instruction *opI = dyn_cast(V)) { + if (!BlocksToExtract.count(opI->getParent())) + inputs.push_back(opI); + } else if (isa(V)) + inputs.push_back(V); } } else { // All other instructions go through the generic input finder