This is an archive of the discontinued LLVM Phabricator instance.

[RegisterBankInfo] Remove overly-agressive asserts
ClosedPublic

Authored by tstellar on May 12 2017, 11:49 AM.

Details

Summary

We were asserting in RegisterBankInfo if RBI.copyCost() returns
UINT_MAX. This is OK for RegBankSelect::Mode::Fast since we only
try one instruction mapping and can't recover from this, but for
RegBankSelect::Mode::Greedy we will be considering multiple
instruction mappings, so we can recover if we see a UNIT_MAX copy
cost.

The copy cost for one pair of register banks in the AMDGPU backend
will be UNIT_MAX, so this patch will prevent AMDGPU tests from
breaking.

Diff Detail

Repository
rL LLVM

Event Timeline

tstellar created this revision.May 12 2017, 11:49 AM
qcolombet requested changes to this revision.May 12 2017, 11:59 AM
qcolombet added inline comments.
lib/CodeGen/GlobalISel/RegBankSelect.cpp
449 ↗(On Diff #98810)

Add a check for the RepairCost here. Otherwise we are going to have overflow in the following computation.

I.e., if (RepairCost == UINT_MAX)

continue;
This revision now requires changes to proceed.May 12 2017, 11:59 AM
tstellar updated this revision to Diff 98819.May 12 2017, 12:45 PM
tstellar edited edge metadata.

Add early exit to avoid overflow.

tstellar marked an inline comment as done.May 12 2017, 12:45 PM
qcolombet accepted this revision.May 12 2017, 12:58 PM

LGTM, nitpick below

lib/CodeGen/GlobalISel/RegBankSelect.cpp
449 ↗(On Diff #98819)

Add a comment saying that this is an impossible repair cost.

This revision is now accepted and ready to land.May 12 2017, 12:58 PM
This revision was automatically updated to reflect the committed changes.
tstellar added inline comments.May 15 2017, 7:16 AM
lib/CodeGen/GlobalISel/RegBankSelect.cpp
449 ↗(On Diff #98810)

Hi Quentin,

I committed with continue; but after running some more tests, shouldn't it really be:

if (RepairCost == UINT_MAX)

return MappingCost::ImpossibleCost();