Skip to content

Zero out only the first pointer when canceling cleanups, and don't zero out PODs #4400

Closed
@pcwalton

Description

@pcwalton

There's generally no need to zero out PODs, and no need to zero out anything beyond the first pointer of a non-POD data structure containing unique values. (Drop glue can simply bail out at the first null pointer it finds.)

LLVM does not optimize out redundant zeroing out of structs, unless all functions that operate on the struct are inlined and SROA happens. Neither does GCC. I believe (but haven't thought too deeply about it) that this is probably an unsafe optimization with the semantics of C. So this could be a rather large win for code size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions