This is an archive of the discontinued LLVM Phabricator instance.

[CodegenPrepare] Guard against degenerate branches
ClosedPublic

Authored by vchuravy on Aug 23 2019, 8:16 AM.

Details

Summary

Guard against a potential crash observed in https://github.com/JuliaLang/julia/issues/32994#issuecomment-524249628
If two branches are collapsed we can encounter a degenerate conditional branch TBB==FBB.
The subsequent code assumes that they differ, so we exit out early.

Diff Detail

Event Timeline

vchuravy created this revision.Aug 23 2019, 8:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2019, 8:16 AM
spatel added inline comments.Sep 30 2019, 12:33 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
7349–7351

Formatting is off, and how does that work in a debug build? No braces for the 'if'. Might be better to just leave out the LLVM_DEBUG line.

llvm/test/CodeGen/X86/codegen-prepare-collapse.ll
2

Is there some way to create a test with 'opt -codegenprepare -S' rather than 'llc'? That would be preferable since the bug is not x86-specific.
If llc is the only way, then we still probably should produce some CHECK lines for FileCheck by using "utils/update_llc_test_checks.py"

vchuravy updated this revision to Diff 233938.Dec 14 2019, 8:40 AM
  • update aaccording to comments
vchuravy marked 3 inline comments as done.Dec 14 2019, 8:42 AM

Sorry that it took so long for me to finish this.

llvm/test/CodeGen/X86/codegen-prepare-collapse.ll
2

I haven't been able to reproduce the crash with opt, if I recall correctly it needs a fully instantiated TargetMachine to trigger the crash

Unit tests: fail. 57754 tests passed, 1 failed and 719 were skipped.

failed: Clang.Driver/check-time-trace-sections.cpp

clang-format: pass.

Build artifacts: console-log.txt, CMakeCache.txt, test-results.xml, diff.json

spatel accepted this revision.Dec 15 2019, 5:51 AM

LGTM

llvm/lib/CodeGen/CodeGenPrepare.cpp
7348

Nit: Add period at end of comment sentence.

llvm/test/CodeGen/X86/codegen-prepare-collapse.ll
15

typo: occure -> occur

This revision is now accepted and ready to land.Dec 15 2019, 5:51 AM
This revision was automatically updated to reflect the committed changes.
vchuravy marked an inline comment as done.