This is an archive of the discontinued LLVM Phabricator instance.

[CostModel] Fix for cast crash
ClosedPublic

Authored by samparker on Jun 24 2020, 4:45 AM.

Details

Summary

Don't assume that the 'NextLevelOp' is an instruction.

Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=46430

Diff Detail

Event Timeline

samparker created this revision.Jun 24 2020, 4:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2020, 4:45 AM
dfukalov added inline comments.
llvm/lib/Analysis/TargetTransformInfo.cpp
1055–1062

It seems in case !isa<Instruction>(NextLevelOp) we should return TTI::RK_None just like for !NextLevelRD case. Correct me if I'm wrong.

1079–1082

You can just replace cast to dyn_cast here since this recursive call will return TTI::RK_None for nullptr as first parameter.

I don't know this code but at least the crash I saw goes away with the fix. Thanks!

samparker updated this revision to Diff 274474.Jun 30 2020, 7:39 AM
samparker added a reviewer: dfukalov.

Updated according to @dfukalov suggestions.

dfukalov added inline comments.Jul 2 2020, 3:10 AM
llvm/lib/Analysis/TargetTransformInfo.cpp
1081

unreachable return typo )

samparker updated this revision to Diff 275057.Jul 2 2020, 4:17 AM

Thanks, fixed typo.

dfukalov accepted this revision.Jul 2 2020, 6:32 AM
This revision is now accepted and ready to land.Jul 2 2020, 6:32 AM
This revision was automatically updated to reflect the committed changes.