Skip to content

[AUTOMATED] type_match: restrict-qualified variables get the ground-truth type void #94

Open

Description

@mahaloz

Problem

type_match records any variable declared with restrict as the ground-truth type void, so no decompiler can ever match it. gnulib's xvfprintf(FILE *restrict stream, char const *restrict format, va_list args), linked into coreutils printf, shows it:

$ python -c 'from pathlib import Path; from decbench.metrics.type_match import extract_ground_truth_types as g; print([ (v["name"], v["type"], v["size"]) for v in g(Path("results/<run>/O0/coreutils/compiled/printf"))["xvfprintf"] ][:2])'
[('stream', ['void'], 0), ('format', ['void'], 0)]

The expected types are FILE* / _IO_FILE* and char*.

It is common. Over coreutils, grep, gzip, diffutils, bzip2, findutils, tar and shadow at O0, O2 and O2-noinline, 4,412 of 65,715 scored ground-truth variables (6.7%) are affected. By what they really are:

Pointee Variables
char * 2,951
pointer to struct 1,221
void * 240

Other examples: sort's sortlines(struct line *restrict lines, ...), ls's mpsort_with_tmp(void const **restrict base, ...), and tar's rpl_regexec(const regex_t *restrict preg, const char *restrict string, ...).

Fix

  • _parse_type_die (decbench/metrics/type_match.py) has no DW_TAG_restrict_type arm. A variable whose DW_AT_type points at a restrict DIE falls through to return ["void"], 0 (:545).
  • Handle restrict the way const and volatile already are: add it to elif tag in ("DW_TAG_const_type", "DW_TAG_volatile_type"): (:507). DW_TAG_atomic_type (C11 _Atomic) falls through the same way and belongs in the same arm.
  • Nothing is needed on the decompiled side. restrict is not in QUALIFIERS, but no decompiler prints it, and adding it there would be harmless.

Tests

A small DWARF fixture, or a unit test over a compiled void f(char *restrict p), asserting the parameter's ground truth is char* rather than void. Existing scores change only for these 4,412 variables, and only from an unmatchable miss to a normal comparison. Cached ground truth will need a re-extract (scripts/reeval_typematch.py).

Activity

  1. changed the title [-][AUTOMATED] type_match: restrict-qualified variables get the ground-truth type void[/-] [+]type_match: restrict-qualified variables get the ground-truth type void[/+] on Sep 19, 2026
  2. changed the title [-]type_match: restrict-qualified variables get the ground-truth type void[/-] [+][AUTOMATED] type_match: restrict-qualified variables get the ground-truth type void[/+] on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions