From 7c27f34296b2ff7170eeb35d0005cc8e04a1b89c Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Sat, 9 Nov 2024 07:46:12 +0530 Subject: [PATCH] Fix containsOnlyConstantLoad logic --- .../compiler/bir/optimizer/BIRRecordValueOptimizer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIRRecordValueOptimizer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIRRecordValueOptimizer.java index 5b1f5c0e8e7d..408a1e3da028 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIRRecordValueOptimizer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIRRecordValueOptimizer.java @@ -192,7 +192,8 @@ private boolean containsOnlyConstantLoad(BIRNode.BIRFunction defaultFunction) { } BIRNode.BIRBasicBlock firstBB = defaultFunction.basicBlocks.get(0); BIRNode.BIRBasicBlock secondBB = defaultFunction.basicBlocks.get(1); - if (!secondBB.instructions.isEmpty() || secondBB.terminator.kind != InstructionKind.RETURN) { + if (!secondBB.instructions.isEmpty() || secondBB.terminator.kind != InstructionKind.RETURN || + firstBB.terminator.kind == InstructionKind.CALL) { return false; } return switch (firstBB.instructions.size()) {