This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Add detector function for explicitly expressed guards
ClosedPublic

Authored by mkazantsev on Dec 25 2018, 2:40 AM.

Details

Summary

This patch adds a function to detect guards expressed in explicit form:

  %wc = call i1 @llvm.experimental.widenable.condition()
  %guard_cond = and i1, %some_cond, %wc
  br i1 %guard_cond, label %guarded, label %deopt

deopt:
  <maybe some non-side-effecting instructions>
  deoptimize()

This form can be used as alternative to implicit control flow guard
representation expressed by experimental_guard intrinsic.

Diff Detail

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.Dec 25 2018, 2:40 AM
apilipenko added inline comments.Jan 9 2019, 4:53 PM
lib/Analysis/GuardUtils.cpp
30 ↗(On Diff #179488)

Why do we need this restriction?

reames accepted this revision.Jan 16 2019, 5:17 PM

LGTM w/one required change.

include/llvm/Analysis/GuardUtils.h
23 ↗(On Diff #179488)

This comment applies to your whole set of reviews.

I would suggest avoiding the term "explicit". Despite glancing at your patch titles a few times over the last week, I still get confused each time. Is explicit the guard? Or the widenable condition? Possible alternate wording:
isWidenableBranchToDeopt?
isGuardAsWidenableBranch?

This revision is now accepted and ready to land.Jan 16 2019, 5:17 PM
mkazantsev marked an inline comment as done.Jan 21 2019, 9:00 PM
mkazantsev added inline comments.
lib/Analysis/GuardUtils.cpp
30 ↗(On Diff #179488)

The simplest example is that there is a throwing call before the deopt, we may never actually go to deopt, and this is not what we want here.

This revision was automatically updated to reflect the committed changes.