@@ -2941,26 +2941,35 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel preSteps (contf: FakeUnit -> Fa
29412941 // Compiler generated sequential executions result in suppressions of debug points on both
29422942 // left and right of the sequence
29432943 let spStmt , spExpr =
2944- ( match spSeq with
2945- | DebugPointAtSequential.SuppressNeither -> SPAlways, SPAlways
2946- | DebugPointAtSequential.SuppressStmt -> SPSuppress, sp
2947- | DebugPointAtSequential.SuppressExpr -> sp, SPSuppress
2948- | DebugPointAtSequential.SuppressBoth -> SPSuppress, SPSuppress)
2944+ match spSeq with
2945+ | DebugPointAtSequential.SuppressNeither -> SPAlways, SPAlways
2946+ | DebugPointAtSequential.SuppressStmt -> SPSuppress, sp
2947+ | DebugPointAtSequential.SuppressExpr -> sp, SPSuppress
2948+ | DebugPointAtSequential.SuppressBoth -> SPSuppress, SPSuppress
2949+
29492950 match specialSeqFlag with
29502951 | NormalSeq ->
29512952 GenExpr cenv cgbuf eenv spStmt e1 discard
29522953 GenLinearExpr cenv cgbuf eenv spExpr e2 sequel true contf
29532954 | ThenDoSeq ->
2954- let g = cenv.g
2955- let isUnit = isUnitTy g ( tyOfExpr g e1)
2956- if isUnit then
2957- GenExpr cenv cgbuf eenv spExpr e1 discard
2958- GenExpr cenv cgbuf eenv spStmt e2 discard
2959- GenUnitThenSequel cenv eenv e2.Range eenv.cloc cgbuf sequel
2960- else
2961- GenExpr cenv cgbuf eenv spExpr e1 Continue
2962- GenExpr cenv cgbuf eenv spStmt e2 discard
2963- GenSequel cenv eenv.cloc cgbuf sequel
2955+ // "e then ()" with DebugPointAtSequential.SuppressStmt is used
2956+ // in mkDebugPoint to emit a debug point on "e". However we don't want this to interfere
2957+ // with tailcalls, so detect this case and throw the "then ()" away, having already
2958+ // worked out "spExpr" up above.
2959+ match e2 with
2960+ | Expr.Const ( Const.Unit, _, _) ->
2961+ GenExpr cenv cgbuf eenv spExpr e1 sequel
2962+ | _ ->
2963+ let g = cenv.g
2964+ let isUnit = isUnitTy g ( tyOfExpr g e1)
2965+ if isUnit then
2966+ GenExpr cenv cgbuf eenv spExpr e1 discard
2967+ GenExpr cenv cgbuf eenv spStmt e2 discard
2968+ GenUnitThenSequel cenv eenv e2.Range eenv.cloc cgbuf sequel
2969+ else
2970+ GenExpr cenv cgbuf eenv spExpr e1 Continue
2971+ GenExpr cenv cgbuf eenv spStmt e2 discard
2972+ GenSequel cenv eenv.cloc cgbuf sequel
29642973 contf Fake
29652974
29662975 | Expr.Let ( bind, body, _, _) ->
0 commit comments