From d4537819f10404d2a0e1a8b4098981b0e0491bf5 Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Fri, 22 Dec 2023 14:32:53 +0100 Subject: [PATCH 1/2] fix merging outputLocals when they are the same Local --- .../sootup/java/bytecode/frontend/OperandMerging.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java index 1fe7d43446c..b1f4e233192 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java @@ -68,11 +68,11 @@ final class OperandMerging { void mergeOutput(@Nonnull Operand outputOperand) { if (output == null) { output = outputOperand; - } else { - if (output.stackLocal != null) { - assert outputOperand.stackLocal == null; - outputOperand.changeStackLocal(output.stackLocal); + } else if (output.stackLocal != null) { + if (output.stackLocal != outputOperand.stackLocal && outputOperand.stackLocal != null) { + throw new IllegalStateException("Incompatible StackLocals. There already exists more than one StackLocal (" + outputOperand.stackLocal + " != " + output.stackLocal+")."); } + outputOperand.changeStackLocal(output.stackLocal); } } From ffb873cba4ab5e623f718c07fe154439bb4e8f0a Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Fri, 22 Dec 2023 15:35:34 +0100 Subject: [PATCH 2/2] dont call changeStackLocal when we already know its the same stacklocal --- .../java/bytecode/frontend/OperandMerging.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java index b1f4e233192..4882ddc17b0 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/OperandMerging.java @@ -69,10 +69,18 @@ void mergeOutput(@Nonnull Operand outputOperand) { if (output == null) { output = outputOperand; } else if (output.stackLocal != null) { - if (output.stackLocal != outputOperand.stackLocal && outputOperand.stackLocal != null) { - throw new IllegalStateException("Incompatible StackLocals. There already exists more than one StackLocal (" + outputOperand.stackLocal + " != " + output.stackLocal+")."); + if (outputOperand.stackLocal == null) { + outputOperand.changeStackLocal(output.stackLocal); + } else { + if (output.stackLocal != outputOperand.stackLocal) { + throw new IllegalStateException( + "Incompatible stacklocal mismatch. There exist multiple, different possible output Locals (" + + outputOperand.stackLocal + + ", " + + output.stackLocal + + ")."); + } } - outputOperand.changeStackLocal(output.stackLocal); } }