wuica-cli 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,8 @@ const MARKER = /^\s*(?:#|\/\/|;)\s*(?:LLVM-MCA-BEGIN|wuica-begin)(?![\w-])/im;
29
29
  const IACA = /^\s*mov[l]?\s+(?:ebx\s*,\s*111|\$111\s*,\s*%ebx)\s*$/im;
30
30
  const LABELS = /^(?:\s*(?:[\w.$@]+|"[^"]*")\s*:)*\s*/;
31
31
  const LABEL_ONE = /\s*([\w.$@]+|"[^"]*")\s*:/y;
32
+ // data directives: bytes in the code that are not an instruction's line
33
+ const DATA = /^(?:byte|short|word|hword|long|int|quad|octa|zero|fill|space|skip|ascii|asciz|string(?:8|16|32|64)?|[248]byte|value|single|float|double|[su]leb128|incbin|dc(?:b|\.\w)?|ds(?:\.\w)?)$/;
32
34
  const PREFIX = /^(?:lock|rep|repe|repz|repne|repnz|bnd|notrack|data16|data32|addr32|cs|ds|es|ss|fs|gs|rex(?:\.\w+)?|\{[\w ]+\})$/i;
33
35
  export const JCC = /^(?:j(?:a|ae|b|be|c|e|g|ge|l|le|na|nae|nb|nbe|nc|ne|ng|nge|nl|nle|no|np|ns|nz|o|p|pe|po|s|z|rcxz|ecxz)|loop(?:e|ne|z|nz)?|xbegin)$/i;
34
36
  export const JMP = /^jmp[lqw]?$/i;
@@ -37,7 +39,9 @@ const RET = /^ret[lqw]?$/i;
37
39
  const SYMBOL = /^[A-Za-z_.$@][\w.$@]*$/;
38
40
  const GPR = /^(?:[re]?(?:ax|bx|cx|dx|si|di|sp|bp|ip)|[abcd][lh]|(?:si|di|sp|bp)l|r(?:[89]|1[0-5])[dwb]?)$/i;
39
41
 
40
- export const OUTSIDE_PREFIX = '.Lwuica_x'; // an objdump branch to an address that is not in the text
42
+ export const OUTSIDE_PREFIX = '.Lwuica_x';
43
+ // directives after which the lines of a text are not its instructions one to one
44
+ const STRUCTURAL = /^[ \t]*(?:[\w.$@]+:[ \t]*)*(\.(?:rept|irpc?|macro|if\w*))\b/im; // an objdump branch to an address that is not in the text
41
45
  const ADDR_LABEL = (a) => `.Lwuica_a${a.toString(16)}`;
42
46
 
43
47
  // Splits a line (block comments already removed) into its statements outside comments: [{at, text}] (at: the column
@@ -63,13 +67,14 @@ export function statements(line) {
63
67
  // The syntax of assembly text: 'att' or 'intel' (null: no sign of either). A directive (.att_syntax, .intel_syntax
64
68
  // [noprefix]) before the first instruction decides; else the signs: AT&T's %registers, $immediates and (%base,...)
65
69
  // memory operands against Intel's "ptr [" and [register...] operands. Comments are left out.
70
+ /** @returns {'att' | 'intel' | null} */
66
71
  export function detectSyntax(text) {
67
72
  const lines = normalizeText(text).split('\n');
68
73
  let att = 0, intel = 0;
69
74
  for (const l of lines) {
70
75
  const code = l.replace(/(?:#|\/\/).*$/, '');
71
76
  const d = /^\s*\.(att|intel)_syntax\b/i.exec(code);
72
- if (d && att + intel === 0) return d[1].toLowerCase();
77
+ if (d && att + intel === 0) return /** @type {'att' | 'intel'} */ (d[1].toLowerCase());
73
78
  const n = syntaxSigns(code);
74
79
  att += n.att;
75
80
  intel += n.intel;
@@ -119,13 +124,16 @@ function byteColumn(rest) {
119
124
  // One-byte instructions that have operands (an objdump step of 1 for an instruction with operands must be one of these).
120
125
  const ONE_BYTE = /^(?:push|pop|xchg|in|out|ins\w*|outs\w*|stos\w*|lods\w*|movs\w*|scas\w*|cmps\w*|bswap|int)$/i;
121
126
 
122
- // {text, objdump: true, addresses: Map line -> address, bytes: Map line -> the line as .byte} or {objdump: false}.
127
+ // {text, objdump: true, addresses: Map line -> address, bytes: Map line -> the line as .byte, sources: Map line -> the
128
+ // source line in force (objdump -dS, -S: the interleaved source text, llvm-objdump's after "; ")} or {objdump: false}.
129
+ /** @returns {any} */
123
130
  export function fromObjdump(text) {
124
131
  const lines = normalizeText(text).split('\n');
125
132
  let header = false, symbolic = false, column = false, increasing = true, other = 0, plausible = true;
126
133
  const rows = [];
134
+ let last = -1; // (addresses increase within a function; perf annotate prints its functions in any order)
127
135
  for (const l of lines) {
128
- if (OD_HEADER.test(l)) { header = true; continue; }
136
+ if (OD_HEADER.test(l)) { header = true; last = -1; continue; }
129
137
  if (OD_NOISE.test(l) || /^\s*(?:$|#|\/\/|;)/.test(l)) continue;
130
138
  const m = OD_ADDR.exec(l);
131
139
  if (!m) { other++; continue; }
@@ -133,7 +141,8 @@ export function fromObjdump(text) {
133
141
  if (/<[^>]*>/.test(m[4])) symbolic = true;
134
142
  const bc = byteColumn(m[4]);
135
143
  if (bc.bytes && /\t| /.test(m[4])) column = true;
136
- if (rows.length && a <= rows.at(-1).a) increasing = false;
144
+ if (a <= last) increasing = false;
145
+ last = a;
137
146
  rows.push({ a, rest: bc.rest });
138
147
  }
139
148
  if (rows.length < 2 || !increasing) return { objdump: false };
@@ -150,6 +159,7 @@ export function fromObjdump(text) {
150
159
  if (rows.some((r) => /^\s*(?:\S+\s+)*?(?:j[a-z]{1,4}|jmp\w*|call\w*|loop[a-z]*)\s+\d+[bf]\s*$/i.test(r.rest))) return { objdump: false };
151
160
  }
152
161
 
162
+ /** @type {any[]} */
153
163
  const parsed = lines.map((l) => {
154
164
  // a function's header ("0000000000000020 <fir8>:") becomes its label (the loops' function), if it is a plain name
155
165
  const fh = /^\s*[0-9a-fA-F]+\s+<([A-Za-z_][\w.$]*)>:\s*$/.exec(l);
@@ -182,6 +192,21 @@ export function fromObjdump(text) {
182
192
  else name = `${OUTSIDE_PREFIX}${t.toString(16)}`;
183
193
  p.text = `${b[1]}${b[2]}${b[3]}${name}`;
184
194
  }
195
+ // objdump -S: a source line (llvm-objdump: "; text"; GNU objdump: the text itself) holds for the instructions after it,
196
+ // up to the next one or the next function; GNU's -l lines ("/path/file.c:12", "dot():") are not source text
197
+ const sources = new Map();
198
+ /** @type {string | null} */
199
+ let src = null;
200
+ lines.forEach((l, k) => {
201
+ const p = parsed[k];
202
+ if (p.kind === 'instr') { if (src !== null) sources.set(k + 1, src); return; }
203
+ if (/^\s*[0-9a-fA-F]+\s+<[^>]*>:\s*$/.test(l)) { src = null; return; }
204
+ if (OD_HEADER.test(l) || OD_NOISE.test(l) || p.kind === 'more' || /^\s*$/.test(l) || /^\s*\/\//.test(l)) return;
205
+ // (llvm-objdump's "; " is "# " here: a ';' that starts a line is read as '#', leadingSemicolons)
206
+ const t = l.replace(/^\s*[;#]\s?/, '').trim();
207
+ if (!t || /^\S+:\d+(?:\s*\(discriminator \d+\))?$/.test(t) || /^[\w.$]+\(\):$/.test(t)) return;
208
+ src = t;
209
+ });
185
210
  const addresses = new Map(), byteMap = new Map();
186
211
  const out = parsed.map((p, k) => {
187
212
  if (p.kind === 'blank' || p.kind === 'more') return '';
@@ -191,7 +216,62 @@ export function fromObjdump(text) {
191
216
  if (p.bytes?.length) byteMap.set(k + 1, `${p.indent}${label}.byte ${p.bytes.map((b) => '0x' + b.toString(16).padStart(2, '0')).join(', ')}`);
192
217
  return `${p.indent}${label}${p.text}`;
193
218
  });
194
- return { objdump: true, text: out.join('\n'), addresses, bytes: byteMap };
219
+ return { objdump: true, text: out.join('\n'), addresses, bytes: byteMap, sources };
220
+ }
221
+
222
+ // ---- perf annotate --------------------------------------------------------------------------------------------------
223
+
224
+ // `perf annotate --stdio` output: one block per symbol, each with its header ("Percent | Source code & Disassembly of hot
225
+ // for cycles:u (1069 samples, percent: local period)") and its lines: an instruction " 22.59 : 1413: movaps ...",
226
+ // anything else after an empty percent column " :" (perf 7 numbers those lines: " : 39 s += m[...]"). Read as the same
227
+ // lines of objdump text (an instruction as " 1413:\tmovaps ...", a source line as "; text", the function header as is),
228
+ // line for line. samples: Map line -> the instruction's percent of all the samples of the output: a block's local
229
+ // percentages (perf's default) are of its own symbol's samples, weighted by the sample count of its header (an
230
+ // approximation of perf's global-period, which weighs by period); global ones, or without a header, as given. {text,
231
+ // perf: true, samples} or {perf: false} (stdio2: true for `perf annotate --stdio2` output, which has no addresses).
232
+ const PERF_INSN = /^\s*(\d+(?:\.\d+)?)\s*:\s+([0-9a-fA-F]+):\s+(\S.*)$/;
233
+ const PERF_OTHER = /^\s*:\s?(.*)$/;
234
+ const PERF_HEADER = /^\s*Percent\s*\|/;
235
+ const PERF_COUNT = /\((\d[\d,.'\u00a0\u202f]*) samples\b/; // (with a locale's thousands separators: "5,000")
236
+ const PERF_TYPE = /percent: ([^),]*)/;
237
+ /** @returns {any} */
238
+ export function fromPerfAnnotate(text) {
239
+ const lines = normalizeText(text).split('\n');
240
+ if (lines.filter((l) => PERF_INSN.test(l)).length < 2 || !lines.some((l) => /^\s*Percent\s*\|/.test(l) || PERF_OTHER.test(l))) {
241
+ const stdio2 = /^Samples: .*\[percent: /m.test(lines.slice(0, 5).join('\n')) && lines.some((l) => /^Percent\s{2,}\S/.test(l));
242
+ return { perf: false, stdio2 };
243
+ }
244
+ const local = new Map(); // line -> [percent, its block]
245
+ /** @type {{samples: number | null, global: boolean}[]} */
246
+ const blocks = [];
247
+ /** @type {{samples: number | null, global: boolean} | null} */
248
+ let block = null;
249
+ const out = lines.map((l, k) => {
250
+ if (PERF_HEADER.test(l)) {
251
+ // each header its own count (none: unknown, not the previous header's); --percent-type global-*: already of all
252
+ // the samples
253
+ const n = PERF_COUNT.exec(l);
254
+ block = { samples: n ? Number(n[1].replace(/\D/g, '')) : null, global: /global/.test(PERF_TYPE.exec(l)?.[1] ?? '') };
255
+ blocks.push(block);
256
+ return '';
257
+ }
258
+ const m = PERF_INSN.exec(l);
259
+ if (m) { local.set(k + 1, [Number(m[1]), block]); return ` ${m[2]}:\t${m[3].trim()}`; }
260
+ const o = PERF_OTHER.exec(l);
261
+ if (!o) return ''; // the header's rule, a summary
262
+ const t = o[1].trim().replace(/^\d+\s+/, ''); // (perf 7: the listing's line number first)
263
+ if (!t || /^Disassembly of section\b/.test(t)) return '';
264
+ if (/^[0-9a-fA-F]+\s+<[^>]*>:$/.test(t)) return t;
265
+ return `; ${t}`;
266
+ });
267
+ // the percent of all samples: each block's local percentages weighted by its samples, if every such block has its
268
+ // count (one block: as given); else each symbol's own percentages, as given (unweighted: true)
269
+ const locals = blocks.filter((b) => !b.global);
270
+ const unweighted = locals.length > 1 && locals.some((b) => b.samples === null);
271
+ const total = unweighted ? 0 : locals.reduce((a, b) => a + (b.samples ?? 0), 0);
272
+ const samples = new Map();
273
+ for (const [line, [p, b]] of local) samples.set(line, total > 0 && b && !b.global && b.samples !== null ? Math.round(p * b.samples / total * 100) / 100 : p);
274
+ return { perf: true, text: out.join('\n'), samples, unweighted };
195
275
  }
196
276
 
197
277
  // ---- the statements of a text ----------------------------------------------------------------------------------------
@@ -208,19 +288,21 @@ const sectionName = (args) => (/^\s*("?)([^",\s]+)\1/.exec(args)?.[2] ?? '');
208
288
  export const isText = (args) => { const n = sectionName(args); return n === '.text' || n.startsWith('.text.'); };
209
289
 
210
290
  // {labels: Map name -> line, symbols: Set (assigned with = / .set / .equ), instrs: [{line, col, mnemonic, operands,
211
- // kind: 'jcc' | 'jmp' | 'call' | 'ret' | 'other', target}], numeric: [{name, line}]}. Lines 1-based; only .text code.
291
+ // kind: 'jcc' | 'jmp' | 'call' | 'ret' | 'other', target}], numeric: [{name, line}], data: [line]}. Lines 1-based; only
292
+ // .text code. A prefix alone on its line ("lock", then "add [rdi], eax") is part of the next instruction, not one of its
293
+ // own; data: the lines of data directives in code (.byte, .fill, ...: bytes the instructions cannot be told from).
212
294
  export function scan(text) {
213
295
  const raw = String(text).split('\n');
214
296
  const lines = blankBlockComments(String(text)).split('\n');
215
297
  // clang's loop notes on a label's line or the comment line after it ("# =>This Inner Loop Header: Depth=2",
216
298
  // "# in Loop: Header=BB0_4 Depth=1"): label -> text
217
299
  const notes = new Map();
218
- const labels = new Map(), symbols = new Set(), instrs = [], numeric = [], functions = new Set();
300
+ const labels = new Map(), symbols = new Set(), instrs = [], numeric = [], functions = new Set(), data = [];
219
301
  let inText = true, prev = true, directives = 0;
220
302
  const stack = [];
221
303
  for (let i = 0; i < lines.length; i++) {
222
304
  for (const st of statements(lines[i])) {
223
- const lead = LABELS.exec(st.text)[0].length;
305
+ const lead = /** @type {RegExpExecArray} */ (LABELS.exec(st.text))[0].length;
224
306
  LABEL_ONE.lastIndex = 0;
225
307
  let m;
226
308
  const head = st.text.slice(0, lead);
@@ -240,6 +322,7 @@ export function scan(text) {
240
322
  const name = d?.[1].toLowerCase() ?? '';
241
323
  const args = d?.[2] ?? '';
242
324
  directives++;
325
+ if (inText && DATA.test(name)) data.push(i + 1);
243
326
  if (name === 'set' || name === 'equ' || name === 'equiv') { const s = /^([\w.$@]+)/.exec(args); if (s) symbols.add(s[1]); }
244
327
  else if (name === 'globl' || name === 'global') { const s = /^([\w.$@]+)/.exec(args); if (s) functions.add(s[1]); }
245
328
  else if (name === 'type') { const s = /^([\w.$@]+)\s*,\s*[@%]function/.exec(args); if (s) functions.add(s[1]); }
@@ -254,6 +337,7 @@ export function scan(text) {
254
337
  const assign = /^([\w.$@]+)\s*=/.exec(body);
255
338
  if (assign) { symbols.add(assign[1]); continue; }
256
339
  if (!inText) continue;
340
+ if (body.split(/\s+/).every((w) => PREFIX.test(w))) continue; // a prefix alone: the next instruction's
257
341
  const { mnemonic, operands } = splitInstr(body);
258
342
  let kind = 'other', target = null;
259
343
  if (JCC.test(mnemonic)) kind = 'jcc';
@@ -267,7 +351,7 @@ export function scan(text) {
267
351
  instrs.push({ line: i + 1, col: st.at + lead, end: st.at + st.text.length, mnemonic, operands, kind, target, body });
268
352
  }
269
353
  }
270
- return { labels, symbols, instrs, numeric, functions, directives, notes };
354
+ return { labels, symbols, instrs, numeric, functions, directives, notes, data };
271
355
  }
272
356
 
273
357
  // The line a branch target refers to (a label, or a numeric label "1b" / "1f" seen from `line`), or null.
@@ -307,7 +391,7 @@ export function findLoops(s) {
307
391
  const keyOf = (label) => {
308
392
  const n = s.notes.get(label) ?? '';
309
393
  if (/This (?:Inner )?Loop Header/.test(n) || !/Header=(\w+)/.test(n)) return label.replace(/^\.L/, '');
310
- return /Header=(\w+)/.exec(n)[1];
394
+ return /** @type {RegExpExecArray} */ (/Header=(\w+)/.exec(n))[1];
311
395
  };
312
396
  const groups = new Map();
313
397
  for (const l of real) {
@@ -374,10 +458,18 @@ export function functionBody(s) {
374
458
  // What to analyze: see the top. text: the pasted assembly; loop: 'auto' (default), 'whole', or the index of a loop.
375
459
  // Returns {text, objdump, loops: [{begin, end, label}], choice: index | 'body' | null, choosable (there is code around the
376
460
  // loop or the body: a choice matters), pick: {begin, end, lines: [the line of each instruction]} | null,
377
- // body: {begin, end} | null, alignment: number | null, address: number | null, stubs: [names],
461
+ // body: {begin, end} | null, alignment: number | null, address: number | null, stubs: [names], lines: [the line of each
462
+ // instruction of the text],
378
463
  // notes: [{line, column, severity, message}], fallback: Map line -> text, error?}
464
+ /**
465
+ * @param {string} text
466
+ * @param {{loop?: string | number, func?: string | null}} [opts]
467
+ * @returns {any}
468
+ */
379
469
  export function preparePaste(text, { loop = 'auto', func = null } = {}) {
380
- let t = leadingSemicolons(normalizeText(text).replace(/^/, ''));
470
+ const pf = fromPerfAnnotate(normalizeText(text).replace(/^/, ''));
471
+ if (pf.stdio2) return { error: 'input: this is perf annotate --stdio2 output, which has no addresses: use perf annotate --stdio', loops: [] };
472
+ let t = leadingSemicolons(pf.perf ? pf.text : normalizeText(text).replace(/^/, ''));
381
473
  const od = fromObjdump(t);
382
474
  if (od.objdump) t = od.text;
383
475
  // code sections other than .text (gcc's main in .text.startup, -ffunction-sections): into .text, which the assembler
@@ -396,7 +488,8 @@ export function preparePaste(text, { loop = 'auto', func = null } = {}) {
396
488
  const named = (l) => (l.label.startsWith('.Lwuica_a') ? `0x${l.label.slice(9)}` : l.label);
397
489
  // a loop by its label ("-loop .LBB0_12", "-loop 0x10"): as its index
398
490
  if (typeof loop === 'string' && loop !== 'auto' && loop !== 'whole') {
399
- const hits = loops.flatMap((l, i) => (named(l) === loop || l.label === loop || named(l) === `.${loop}` || (/^0x/i.test(loop) && named(l).toLowerCase() === loop.toLowerCase()) ? [i] : []));
491
+ const name = loop;
492
+ const hits = loops.flatMap((l, i) => (named(l) === name || l.label === name || named(l) === `.${name}` || (/^0x/i.test(name) && named(l).toLowerCase() === name.toLowerCase()) ? [i] : []));
400
493
  const k = hits.length ? hits[0] : -1;
401
494
  // the same label in several functions (numeric labels: "1:" ... "jnz 1b"): not a guess
402
495
  if (hits.length > 1) return { error: `loop: ${JSON.stringify(loop)} names ${hits.length} loops (${hits.map((i) => `${i} in ${loops[i].function ?? 'no function'}`).join(', ')}): -func NAME or -loop N (0-based) picks one`, loops: [] };
@@ -410,6 +503,7 @@ export function preparePaste(text, { loop = 'auto', func = null } = {}) {
410
503
  for (const [line, b] of od.bytes) lines[line - 1] = b;
411
504
  asm = lines.join('\n');
412
505
  }
506
+ /** @type {any} */
413
507
  const out = { text: asm, objdump: od.objdump, loops: loops.map((l) => ({ begin: l.begin, end: l.end, label: named(l), function: l.function, instructions: l.instructions, depth: l.depth, inner: l.inner })),
414
508
  choice: null, choosable: false, pick: null, body: null, alignment: null, address: null, stubs: [], notes: [], fallback: new Map() };
415
509
  if (loop !== 'auto' && loop !== 'whole' && !(Number.isInteger(loop) && loop >= 0)) {
@@ -417,7 +511,33 @@ export function preparePaste(text, { loop = 'auto', func = null } = {}) {
417
511
  return out;
418
512
  }
419
513
  const code = s.instrs;
420
- if (Number.isInteger(loop) && loop >= loops.length) {
514
+ // .rept, .irp, .irpc, .macro and .if* make a line something else than one instruction (repeated, left out, a macro's
515
+ // call): no source lines then, and no loop picked (it could not be isolated): the whole text, said in a note
516
+ const structural = STRUCTURAL.exec(t);
517
+ out.exactLines = !structural;
518
+ if (structural && loop !== 'whole' && loops.length) {
519
+ const at = t.slice(0, structural.index).split('\n').length;
520
+ out.notes.push({ line: at, column: null, severity: 'note', message: `${structural[1]}: the text repeats or leaves out lines, so a loop cannot be isolated: the whole text is analyzed` });
521
+ loop = 'whole';
522
+ }
523
+ out.lines = code.map((x) => x.line);
524
+ // per instruction line: the interleaved source line (objdump -S, perf annotate) and the percent of samples (perf)
525
+ out.lineInfo = new Map();
526
+ for (const x of code) {
527
+ const source = od.objdump ? od.sources?.get(x.line) : undefined, samples = pf.perf ? pf.samples.get(x.line) : undefined;
528
+ if (source !== undefined || samples !== undefined) out.lineInfo.set(x.line, { ...(source !== undefined ? { source } : {}), ...(samples !== undefined ? { samples } : {}) });
529
+ }
530
+ out.profile = pf.perf ? 'perf' : null;
531
+ if (pf.unweighted) out.notes.push({ line: null, column: null, severity: 'note', message: 'perf annotate: a symbol\'s header has no sample count, so the samples are each symbol\'s own percentages (not of all the samples)' });
532
+ // perf annotate with several loops: "auto" picks the one whose own instructions (not those of a loop nested in it)
533
+ // have the most samples, the first of equals
534
+ if (pf.perf && loop === 'auto' && loops.length > 1) {
535
+ const inside = (a, b) => a !== b && a.begin >= b.begin && a.end <= b.end;
536
+ const heat = loops.map((l) => code.filter((x) => x.line >= l.begin && x.line <= l.end && !loops.some((n) => inside(n, l) && x.line >= n.begin && x.line <= n.end))
537
+ .reduce((n, x) => n + (pf.samples.get(x.line) ?? 0), 0));
538
+ loop = heat.indexOf(Math.max(...heat));
539
+ }
540
+ if (Number.isInteger(loop) && Number(loop) >= loops.length) {
421
541
  out.error = `loop: ${loop} is not the index of a loop (0-based; the text has ${loops.length === 0 ? 'none' : `${loops.length}: 0 to ${loops.length - 1}`})`;
422
542
  return out;
423
543
  }
@@ -428,7 +548,7 @@ export function preparePaste(text, { loop = 'auto', func = null } = {}) {
428
548
  // a compiler's function (a function label, directives, objdump, or a prologue/epilogue): its body; a bare snippet
429
549
  // ("add rax, 1 / ret") is analyzed as typed
430
550
  const b = functionBody(s);
431
- const compiled = od.objdump || s.directives > 0 || [...s.labels.keys()].some((n) => !n.startsWith('.L') && !/^\d+$/.test(n)) || b?.trimmed > 0;
551
+ const compiled = od.objdump || s.directives > 0 || [...s.labels.keys()].some((n) => !n.startsWith('.L') && !/^\d+$/.test(n)) || (b?.trimmed ?? 0) > 0;
432
552
  out.body = b && compiled ? { begin: b.begin, end: b.end } : null;
433
553
  out.choosable = !!out.body;
434
554
  }
@@ -445,6 +565,9 @@ export function preparePaste(text, { loop = 'auto', func = null } = {}) {
445
565
  out.pick = { ...out.pick, lines: code.filter((x) => x.line >= out.pick.begin && x.line <= out.pick.end).map((x) => x.line) };
446
566
  }
447
567
  }
568
+ // data directives among the analyzed instructions (the pick's, or the whole text's): their bytes are instructions of
569
+ // their own or parts of one, so the lines are not the instructions one to one: none
570
+ if (s.data.some((l) => !out.pick || (l >= out.pick.begin && l <= out.pick.end))) out.exactLines = false;
448
571
  // the exits: conditional branches (and jumps to .L labels) whose target the text does not define
449
572
  const defined = (name) => s.labels.has(name) || s.symbols.has(name);
450
573
  const seen = new Set();