Skip to content

Fix the three translator emitters that produce all 144 generated-C warnings #5780

Description

@shai-almog

The generated C is down to 3 warning shapes / 144 instances on the iOS
simulator leg, from 3,035 instances in 8 kinds when the census started. What is
left is three emitter defects, each of which is one fix that erases a whole
category:

instances flag where it comes from
98 -Wunused-variable a C auto is emitted per bytecode local slot
42 -Wparentheses-equality if ((a == b)) shape in an emitted condition
4 -Wimplicitly-unsigned-literal a literal too large for a signed int

The unused-variable hypothesis, stated as a hypothesis.
BytecodeMethod.appendMethodC() walks localVariables and emits one C auto per
slot unconditionally, without consulting whether optimize() left a use. Every
method with a slot the optimizer killed then contributes one warning. Confirm
cheaply before writing any code: count how many of the 98 messages in the census
JSON name a locals_N_ identifier. If most do, the fix is at that emission
point.

-Wimplicitly-unsigned-literal (4) is worth reading as a possible bug rather
than a style nit -- it appears in java_lang_Long.m and
com_codename1_sensors_GestureEngine.m, and a literal silently reinterpreted as
unsigned changes comparison results.

Do not suppress these. Blanket-silencing translator output is how a codegen
defect hides forever; the whole point of putting generated C in scope was to fix
the emitters. If a residual genuinely cannot be fixed, the narrow fallback is a
#pragma GCC diagnostic prologue emitted from ByteCodeClass.generateCCode()
-- one emission point, visible in the generated file, and it behaves the same
under Xcode clang, clang-cl and gcc. Use the GCC spelling: gcc does not
understand #pragma clang diagnostic, and -Wunknown-pragmas is inside
-Wall. Every such pragma keeps a matching baseline row, because the pragma
silences the compiler and the row is what a human has to justify.

Acceptance: the generated group reaches 0 instances in the census summary,
and its baseline rows are deleted (stale rows are a hard failure by design).

Found by the native warning census (scripts/check-native-warnings.py).

Activity

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