Commit Graph

111 Commits

Author SHA1 Message Date
Evan Cheng 7fae11b231 - Add MachineInstrBundle.h and MachineInstrBundle.cpp. This includes a function
to finalize MI bundles (i.e. add BUNDLE instruction and computing register def
  and use lists of the BUNDLE instruction) and a pass to unpack bundles.
- Teach more of MachineBasic and MachineInstr methods to be bundle aware.
- Switch Thumb2 IT block to MI bundles and delete the hazard recognizer hack to
  prevent IT blocks from being broken apart.

llvm-svn: 146542
2011-12-14 02:11:42 +00:00
Evan Cheng 7f8e563a69 Add bundle aware API for querying instruction properties and switch the code
generator to it. For non-bundle instructions, these behave exactly the same
as the MC layer API.

For properties like mayLoad / mayStore, look into the bundle and if any of the
bundled instructions has the property it would return true.
For properties like isPredicable, only return true if *all* of the bundled
instructions have the property.
For properties like canFoldAsLoad, isCompare, conservatively return false for
bundles.

llvm-svn: 146026
2011-12-07 07:15:52 +00:00
Benjamin Kramer 1f97a5a671 Remove all remaining uses of Value::getNameStr().
llvm-svn: 144648
2011-11-15 16:27:03 +00:00
Jakob Stoklund Olesen d7bcf43dc2 Use getVNInfoBefore() when it makes sense.
llvm-svn: 144517
2011-11-14 01:39:36 +00:00
Jakob Stoklund Olesen 90b5e565b6 Rename SlotIndexes to match how they are used.
The old naming scheme (load/use/def/store) can be traced back to an old
linear scan article, but the names don't match how slots are actually
used.

The load and store slots are not needed after the deferred spill code
insertion framework was deleted.

The use and def slots don't make any sense because we are using
half-open intervals as is customary in C code, but the names suggest
closed intervals.  In reality, these slots were used to distinguish
early-clobber defs from normal defs.

The new naming scheme also has 4 slots, but the names match how the
slots are really used.  This is a purely mechanical renaming, but some
of the code makes a lot more sense now.

llvm-svn: 144503
2011-11-13 20:45:27 +00:00
Jakob Stoklund Olesen eb38bd8ced Fix sub-register operand verification.
PhysReg operands are not allowed to have sub-register indices at all.

For virtual registers with sub-reg indices, check that all registers in
the register class support the sub-reg index.

llvm-svn: 141220
2011-10-05 22:12:57 +00:00
Jakob Stoklund Olesen 3bb99bc957 Verify that terminators follow non-terminators.
This exposes a -segmented-stacks bug.

llvm-svn: 140429
2011-09-23 22:45:39 +00:00
Andrew Trick 924123acb3 Lower ARM adds/subs to add/sub after adding optional CPSR operand.
This is still a hack until we can teach tblgen to generate the
optional CPSR operand rather than an implicit CPSR def. But the
strangeness is now limited to the selection DAG. ADD/SUB MI's no
longer have implicit CPSR defs, nor do we allow flag setting variants
of these opcodes in machine code. There are several corner cases to
consider, and getting one wrong would previously lead to nasty
miscompilation. It's not the first time I've debugged one, so this
time I added enough verification to ensure it won't happen again.

llvm-svn: 140228
2011-09-21 02:20:46 +00:00
Jakob Stoklund Olesen 4c099551f9 Stop verifying hasPHIKill() flags.
There is only one legitimate use remaining, in addIntervalsForSpills().
All other calls to hasPHIKill() are only used to update PHIKill flags.

The addIntervalsForSpills() function is part of the old spilling
framework, only used by linearscan.

llvm-svn: 139783
2011-09-15 05:16:30 +00:00
Jakob Stoklund Olesen 5670f850c6 Revert "Don't check liveness of unallocatable registers."
The ARM target depends on CPSR liveness being tracked after register
allocation.

llvm-svn: 136548
2011-07-30 00:57:25 +00:00
Jakob Stoklund Olesen 95cc5440e9 Don't check liveness of unallocatable registers.
This includes registers like EFLAGS and ST0-ST7. We don't check for
liveness issues in the verifier and scavenger because registers will
never be allocated from these classes.

While in SSA form, we do care about the liveness of unallocatable
unreserved registers. Liveness of EFLAGS and ST0 neds to be correct for
MachineDCE and MachineSinking.

llvm-svn: 136541
2011-07-29 23:36:21 +00:00
Jakob Stoklund Olesen 9dd184151b Check for multiple defs in the machine code verifier.
llvm-svn: 136535
2011-07-29 23:02:48 +00:00
Evan Cheng 6cc775f905 - Rename TargetInstrDesc, TargetOperandInfo to MCInstrDesc and MCOperandInfo and
sink them into MC layer.
- Added MCInstrInfo, which captures the tablegen generated static data. Chang
TargetInstrInfo so it's based off MCInstrInfo.

llvm-svn: 134021
2011-06-28 19:10:37 +00:00
Evan Cheng 8d71a75777 More refactoring. Move getRegClass from TargetOperandInfo to TargetInstrInfo.
llvm-svn: 133944
2011-06-27 21:26:13 +00:00
Jakob Stoklund Olesen aff1060207 Use TRI::has{Sub,Super}ClassEq() where possible.
No functional change.

llvm-svn: 132455
2011-06-02 05:43:46 +00:00
Cameron Zwarich fe5795a1f6 Revert r128961 because it didn't include a test and causes the verifier to fail
on CodeGen/X86/2007-05-07-InvokeSRet.ll. There is probably a bug here that was
fixed by r128961, but since there is no test or reference to a source file I have
to revert it.

llvm-svn: 131618
2011-05-19 01:56:19 +00:00
Bill Wendling 2a40131f6b SjLj EH could produce a machine basic block that legitimately has more than one
landing pad as its successor.

SjLj exception handling jumps to the correct landing pad via a switch statement
that's generated right before code-gen. Loosen the constraint in the machine
instruction verifier to allow for this. Note, this isn't the most rigorous check
since we cannot determine where that switch statement came from. But it's
marginally better than turning this check off when SjLj exceptions are used.
<rdar://problem/9187612>

llvm-svn: 130881
2011-05-04 22:54:05 +00:00
Jakob Stoklund Olesen 30b5473d82 Permit blocks to branch directly to a landing pad.
Treat the landing pad as a normal successor when that happens.

llvm-svn: 128961
2011-04-05 23:43:11 +00:00
Jakob Stoklund Olesen 561cea0480 Allow kill flags on two-address instructions. They are harmless.
llvm-svn: 128643
2011-03-31 17:52:41 +00:00
Jakob Stoklund Olesen 9a78835414 Mark all uses as <undef> when joining a copy.
This way, shrinkToUses() will ignore the instruction that is about to be
deleted, and we avoid leaving invalid live ranges that SplitKit doesn't like.

Fix a misunderstanding in MachineVerifier about <def,undef> operands. The
<undef> flag is valid on def operands where it has the same meaning as <undef>
on a use operand. It only applies to sub-register defines which also read the
full register.

llvm-svn: 128642
2011-03-31 17:23:25 +00:00
Jakob Stoklund Olesen 66d0f39904 Verify kill flags conservatively.
Allow a live range to end with a kill flag, but don't allow a kill flag that
doesn't end the live range.

This makes the machine code verifier more useful during register allocation when
kill flag computation is deferred.

llvm-svn: 124838
2011-02-04 00:39:18 +00:00
Jakob Stoklund Olesen 58b6f4d832 Verify slot index ordering.
The slot indexes must be monotonically increasing through the function.

llvm-svn: 123324
2011-01-12 21:27:48 +00:00
Jakob Stoklund Olesen b5b4a5d0ba Verify that machine instruction parent pointers are consistent.
llvm-svn: 123322
2011-01-12 21:27:41 +00:00
Jakob Stoklund Olesen 1331a15b0c Replace TargetRegisterInfo::printReg with a PrintReg class that also works without a TRI instance.
Print virtual registers numbered from 0 instead of the arbitrary
FirstVirtualRegister. The first virtual register is printed as %vreg0.
TRI::NoRegister is printed as %noreg.

llvm-svn: 123107
2011-01-09 03:05:53 +00:00
Jakob Stoklund Olesen 6ff70ad356 Fix a MachineVerifier loop that probably didn't mean to skip the last two
virtual registers.

llvm-svn: 123100
2011-01-08 23:11:02 +00:00
Cameron Zwarich 6fe33fdd63 Simplify some code in MachineVerifier that was doing the correct thing, but not
in the most obvious way.

llvm-svn: 122610
2010-12-28 23:45:38 +00:00
Cameron Zwarich b95bfe1667 Add knowledge of phi-def and phi-kill valnos to MachineVerifier's predecessor
valno verification. The "Different value live out of predecessor" check is
incorrect in the case of phi-def valnos, so just skip that check for phi-def
valnos and instead check that all of the valnos for predecessors have phi-kill.
Fixes PR8863.

llvm-svn: 122581
2010-12-27 05:17:23 +00:00
Cameron Zwarich 4ffda706d0 MachineVerifier should count landing pad successors as basic blocks rather than
out-edges. Fixes PR8824.

llvm-svn: 122228
2010-12-20 04:19:48 +00:00
Cameron Zwarich 660bce67f3 Teach MachineVerifier that early clobber defs begin at USE slots and other defs
begin at DEF slots. Fixes the second half of PR8813.

llvm-svn: 122225
2010-12-20 03:15:20 +00:00
Cameron Zwarich bc2461c5f9 Add a missing check from r122218.
llvm-svn: 122224
2010-12-20 02:59:51 +00:00
Cameron Zwarich fc0c6b1ea9 Don't assume that an instruction ending a register's live range always reads
the register; it may be a dead def instead. Fixes PR8820.

llvm-svn: 122218
2010-12-20 01:22:37 +00:00
Cameron Zwarich 1b67d6c565 Ignore debug values when performing MachineVerifier liveness checks. Fixes
PR8822.

llvm-svn: 122207
2010-12-20 00:08:10 +00:00
Cameron Zwarich 0b111b1aee Early clobber operands are allowed to be defined at use indices. This fixes one
half of PR8813.

llvm-svn: 122205
2010-12-19 23:50:53 +00:00
Cameron Zwarich 7e24173a3c Fix PR8811 by teaching MachineVerifier about optional defs.
llvm-svn: 122199
2010-12-19 21:37:23 +00:00
Jakob Stoklund Olesen bf4550e3fb Pass a Banner argument to the machine code verifier both from
createMachineVerifierPass and MachineFunction::verify.

The banner is printed before the machine code dump, just like the printer pass.

llvm-svn: 122113
2010-12-18 00:06:56 +00:00
Jakob Stoklund Olesen a043b62870 Allow missing kill flags on an untied operand of a two-address instruction when
the operand uses the same register as a tied operand:

  %r1 = add %r1, %r1

If add were a three-address instruction, kill flags would be required on at
least one of the uses. Since it is a two-address instruction, the tied use
operand must not have a kill flag.

This change makes the kill flag on the untied use operand optional.

llvm-svn: 122082
2010-12-17 19:18:41 +00:00
Eric Christopher bcc230a765 Only avoid the check if we're the last operand before the variable
operands in a variadic instruction.

llvm-svn: 119446
2010-11-17 00:55:36 +00:00
Eric Christopher 08c083148b Make the verifier a little quieter on instructions that it's probably
(and likely) wrong about anyhow.

llvm-svn: 119320
2010-11-16 01:58:21 +00:00
Jakob Stoklund Olesen 2551f13c83 Be more precise about verifying missing kill flags.
It is legal for an instruction to have two operands using the same register,
only one a kill. This is interpreted as a kill.

llvm-svn: 117981
2010-11-01 23:59:53 +00:00
Jakob Stoklund Olesen d7a824006e Add kill flag verification.
At least X86FloatingPoint requires correct kill flags after register allocation,
and targets using register scavenging benefit. Conservative kill flags are not
enough.

llvm-svn: 117960
2010-11-01 21:51:31 +00:00
Jakob Stoklund Olesen 31fffb62d9 Add basic LiveStacks verification.
When an instruction refers to a spill slot with a LiveStacks entry, check that
the spill slot is live at the instruction.

llvm-svn: 117944
2010-11-01 19:49:52 +00:00
Jakob Stoklund Olesen db84d8f4fd Disable more of physical register live intervals verification.
llvm-svn: 117762
2010-10-30 01:26:11 +00:00
Jakob Stoklund Olesen b98755472e Print out the connected components in the verifier after complaining about their
multiplicity.

llvm-svn: 117630
2010-10-29 00:40:57 +00:00
Jakob Stoklund Olesen dc5e7065a4 One day, physical register live ranges will be sensible.
llvm-svn: 117602
2010-10-28 20:44:22 +00:00
Jakob Stoklund Olesen 0e7a011a00 Physical registers trivially have multiple connected components all the time.
Only virtuals should be requires to be connected.

llvm-svn: 117422
2010-10-27 00:39:01 +00:00
Jakob Stoklund Olesen 260fa289df Verify that live intervals are connected. If there are multiple connected
components, each should get its own virtual register.

llvm-svn: 117407
2010-10-26 22:36:07 +00:00
Jakob Stoklund Olesen b7050233fb Teach MachineBasicBlock::print() to annotate instructions and blocks with
SlotIndexes when available.

llvm-svn: 117392
2010-10-26 20:21:46 +00:00
Jakob Stoklund Olesen db594373bd Remmeber to print full live interval on verification error.
llvm-svn: 117391
2010-10-26 20:21:43 +00:00
Jakob Stoklund Olesen 9eabfa3a39 Don't verify physical registers going into landing pads.
Magic is happening that we don't understand.

llvm-svn: 117370
2010-10-26 16:49:23 +00:00
Jakob Stoklund Olesen 8a09620dc2 Verify LiveIntervals against the CFG, ensuring that live-in values are live-out
of all predecessors.

llvm-svn: 117191
2010-10-23 00:49:09 +00:00