Skip to content

UB optimization leads to really bad code gen #137739

@bwendling

Description

@bwendling

Linux has some code that may result in dividing by zero or shifting by negative numbers. For instance, in one of the ARMGPU drivers, a "divide by zero" results in a fall through into the following function.

drivers/gpu/drm/amd/amdgpu/../display/dc/basics/fixpt31_32.o:
     warning: objtool: dc_fixpt_recip() falls through to next function dc_fixpt_sinc()

drivers/gpu/drm/amd/amdgpu/../display/dc/sspl/spl_fixpt31_32.o:
     warning: objtool: spl_fixpt_recip() falls through to next function spl_fixpt_sinc()

It is undefined behavior, but in these cases it will silently generate incorrect code. It's far better to generate the bad code so that it signals/traps/whatever.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions