@@ -79,7 +79,7 @@ MaybeResult<IRBuilder::HoistedVal> IRBuilder::hoistLastValue() {
79
79
if (type == Type::unreachable) {
80
80
// Make sure the top of the stack also has an unreachable expression.
81
81
if (stack.back ()->type != Type::unreachable) {
82
- push (builder.makeUnreachable ());
82
+ pushSynthetic (builder.makeUnreachable ());
83
83
}
84
84
return HoistedVal{Index (index), nullptr };
85
85
}
@@ -88,7 +88,7 @@ MaybeResult<IRBuilder::HoistedVal> IRBuilder::hoistLastValue() {
88
88
CHECK_ERR (scratchIdx);
89
89
expr = builder.makeLocalSet (*scratchIdx, expr);
90
90
auto * get = builder.makeLocalGet (*scratchIdx, type);
91
- push (get);
91
+ pushSynthetic (get);
92
92
return HoistedVal{Index (index), get};
93
93
}
94
94
@@ -107,7 +107,7 @@ Result<> IRBuilder::packageHoistedValue(const HoistedVal& hoisted,
107
107
scope.exprStack .end ());
108
108
auto * block = builder.makeBlock (exprs, type);
109
109
scope.exprStack .resize (hoisted.valIndex );
110
- push (block);
110
+ pushSynthetic (block);
111
111
};
112
112
113
113
auto type = scope.exprStack .back ()->type ;
@@ -137,33 +137,37 @@ Result<> IRBuilder::packageHoistedValue(const HoistedVal& hoisted,
137
137
scratchIdx = *scratch;
138
138
}
139
139
for (Index i = 1 , size = type.size (); i < size; ++i) {
140
- push (builder.makeTupleExtract (builder.makeLocalGet (scratchIdx, type), i));
140
+ pushSynthetic (
141
+ builder.makeTupleExtract (builder.makeLocalGet (scratchIdx, type), i));
141
142
}
142
143
return Ok{};
143
144
}
144
145
145
- void IRBuilder::push (Expression* expr) {
146
+ void IRBuilder::push (Expression* expr, Origin origin ) {
146
147
auto & scope = getScope ();
147
148
if (expr->type == Type::unreachable) {
148
149
scope.unreachable = true ;
149
150
}
150
151
scope.exprStack .push_back (expr);
151
152
152
- applyDebugLoc (expr);
153
- if (binaryPos && func && lastBinaryPos != *binaryPos) {
154
- auto span =
155
- BinaryLocations::Span{BinaryLocation (lastBinaryPos - codeSectionOffset),
156
- BinaryLocation (*binaryPos - codeSectionOffset)};
157
- // Some expressions already have their start noted, and we are just seeing
158
- // their last segment (like an Else).
159
- auto [iter, inserted] = func->expressionLocations .insert ({expr, span});
160
- if (!inserted) {
161
- // Just update the end.
162
- iter->second .end = span.end ;
163
- // The true start from before is before the start of the current segment.
164
- assert (iter->second .start < span.start );
153
+ if (origin == Origin::Binary) {
154
+ applyDebugLoc (expr);
155
+ if (binaryPos && func && lastBinaryPos != *binaryPos) {
156
+ auto span =
157
+ BinaryLocations::Span{BinaryLocation (lastBinaryPos - codeSectionOffset),
158
+ BinaryLocation (*binaryPos - codeSectionOffset)};
159
+ // Some expressions already have their start noted, and we are just seeing
160
+ // their last segment (like an Else).
161
+ auto [iter, inserted] = func->expressionLocations .insert ({expr, span});
162
+ if (!inserted) {
163
+ // Just update the end.
164
+ iter->second .end = span.end ;
165
+ // The true start from before is before the start of the current
166
+ // segment.
167
+ assert (iter->second .start < span.start );
168
+ }
169
+ lastBinaryPos = *binaryPos;
165
170
}
166
- lastBinaryPos = *binaryPos;
167
171
}
168
172
169
173
DBG (std::cerr << " After pushing " << ShallowExpression{expr} << " :\n " );
@@ -1018,7 +1022,7 @@ Result<> IRBuilder::visitCatch(Name tag) {
1018
1022
// Note that we have a pop to help determine later whether we need to run
1019
1023
// the fixup for pops within blocks.
1020
1024
scopeStack[0 ].notePop ();
1021
- push (builder.makePop (params));
1025
+ pushSynthetic (builder.makePop (params));
1022
1026
}
1023
1027
1024
1028
return Ok{};
0 commit comments