This is an archive of the discontinued LLVM Phabricator instance.

[TargetInstrInfo] Add new hook: AnalyzeBranchPredicate.
ClosedPublic

Authored by sanjoy on Jun 2 2015, 2:38 PM.

Details

Summary

NFC: no one uses AnalyzeBranchPredicate yet.

Add TargetInstrInfo::AnalyzeBranchPredicate and implement for x86. A
later change adding support for page-fault based implicit null checks
depends on this.

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 27009.Jun 2 2015, 2:38 PM
sanjoy retitled this revision from to [TargetInstrInfo] Add new hook: AnalyzeBranchPredicate..
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added reviewers: atrick, reames.
sanjoy added a subscriber: Unknown Object (MLST).
sanjoy added a reviewer: ab.Jun 5 2015, 9:13 AM
sanjoy updated this revision to Diff 27425.Jun 9 2015, 7:42 PM
  • address review: don't use CmpInst::Predicate, but use a separate enum instead
ab edited edge metadata.Jun 12 2015, 4:23 PM

This seems reasonable to me, but I'll let Andy have the final say.

-Ahmed

include/llvm/Target/TargetInstrInfo.h
23

This can go away now, right?

lib/Target/X86/X86InstrInfo.cpp
3619

Why not return true if Cond.size() == 0? (i.e. the branch isn't conditional?)

3642

OpCode -> Opcode

lib/Target/X86/X86InstrInfo.h
169

Inner -> Impl, perhaps?

atrick requested changes to this revision.Jun 12 2015, 4:45 PM
atrick edited edge metadata.

Looks good but I have one comment inline...

lib/Target/X86/X86InstrInfo.cpp
3634–3635

This looks strange to me. Do you really need to prove that the ConditionDef only has a single use? If so, I think you should:

  • check that EFLAGS is not live into any successors
  • Walk backward from the branch looking for a Def of EFLAGS before any other use of EFLAGS.

You may have EFLAGS readers other than conditional branches.
killsRegister is a crutch that should be avoided whenever possible. It might not be accurate.

This revision now requires changes to proceed.Jun 12 2015, 4:45 PM
sanjoy added inline comments.Jun 12 2015, 4:50 PM
lib/Target/X86/X86InstrInfo.cpp
3634–3635

Do you really need to prove that the ConditionDef only has a single use?

Preferably. I'd like to remove the test instruction as part of the implicit null check optimization.

I'll make the change you suggested.

sanjoy updated this revision to Diff 27623.Jun 12 2015, 6:13 PM
sanjoy edited edge metadata.
  • address review
include/llvm/Target/TargetInstrInfo.h
23

Fixed, thanks.

lib/Target/X86/X86InstrInfo.cpp
3619

I agree, this should not be an assert.

3642

Fixed.

lib/Target/X86/X86InstrInfo.h
169

Fixed.

atrick accepted this revision.Jun 12 2015, 6:17 PM
atrick edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jun 12 2015, 6:17 PM
This revision was automatically updated to reflect the committed changes.