This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec] Avoid crashing when SwitchInst doesn't see ConstantInt
ClosedPublic

Authored by thevinster on Jun 29 2023, 3:07 PM.

Details

Summary

D150464 updated the cost model for function specialization. Unfortunately, this
also crashes when trying to build stage2 LLD with thinLTO and assertions. It looks
like the issue is caused by a mishandling of the Constant in a SwitchInst since the
Constant cannot always be assumed to safely casted to a ConstantInt. In the case
of the crash, Constant was a ConstantExpr which triggered the assertion.

Diff Detail

Event Timeline

thevinster created this revision.Jun 29 2023, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 3:07 PM
thevinster published this revision for review.Jun 29 2023, 3:13 PM
thevinster edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 3:14 PM
ChuanqiXu accepted this revision.Jun 29 2023, 6:59 PM

LGTM. Thanks.

llvm/test/Transforms/FunctionSpecialization/function-specialization-constant-expression6.ll
22

nit

This revision is now accepted and ready to land.Jun 29 2023, 6:59 PM
thevinster marked an inline comment as done.Jun 30 2023, 8:58 PM
This revision was landed with ongoing or failed builds.Jun 30 2023, 9:12 PM
This revision was automatically updated to reflect the committed changes.