1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-25 14:02:52 +02:00
llvm-mirror/test
Sanjoy Das 970ff026f0 [MachineBlockPlacement] Don't make blocks "uneditable"
Summary:
This fixes an issue with MachineBlockPlacement due to a badly timed call
to `analyzeBranch` with `AllowModify` set to true.  The timeline is as
follows:

 1. `MachineBlockPlacement::maybeTailDuplicateBlock` calls
    `TailDup.shouldTailDuplicate` on its argument, which in turn calls
    `analyzeBranch` with `AllowModify` set to true.

 2. This `analyzeBranch` call edits the terminator sequence of the block
    based on the physical layout of the machine function, turning an
    unanalyzable non-fallthrough block to a unanalyzable fallthrough
    block.  Normally MBP bails out of rearranging such blocks, but this
    block was unanalyzable non-fallthrough (and thus rearrangeable) the
    first time MBP looked at it, and so it goes ahead and decides where
    it should be placed in the function.

 3. When placing this block MBP fails to analyze and thus update the
    block in keeping with the new physical layout.

Concretely, before (1) we have something like:

```
LBL0:
  < unknown terminator op that may branch to LBL1 >
  jmp LBL1

LBL1:
  ... A

LBL2:
  ... B
```

In (2), analyze branch simplifies this to

```
LBL0:
  < unknown terminator op that may branch to LBL2 >
  ;; jmp LBL1 <- redundant jump removed

LBL1:
  ... A

LBL2:
  ... B
```

In (3), MachineBlockPlacement goes ahead with its plan of putting LBL2
after the first block since that is profitable.

```
LBL0:
  < unknown terminator op that may branch to LBL2 >
  ;; jmp LBL1 <- redundant jump

LBL2:
  ... B

LBL1:
  ... A
```

and the program now has incorrect behavior (we no longer fall-through
from `LBL0` to `LBL1`) because MBP can no longer edit LBL0.

There are several possible solutions, but I went with removing the teeth
off of the `analyzeBranch` calls in TailDuplicator.  That makes thinking
about the result of these calls easier, and breaks nothing in the lit
test suite.

I've also added some bookkeeping to the MachineBlockPlacement pass and
used that to write an assert that would have caught this.

Reviewers: chandlerc, gberry, MatzeB, iteratee

Subscribers: mcrosier, llvm-commits

Differential Revision: https://reviews.llvm.org/D27783

llvm-svn: 289764
2016-12-15 05:08:57 +00:00
..
Analysis Remove the AssumptionCache 2016-12-15 03:02:15 +00:00
Assembler
Bindings
Bitcode
BugPoint
CodeGen [MachineBlockPlacement] Don't make blocks "uneditable" 2016-12-15 05:08:57 +00:00
DebugInfo [InstCombine] Folding of a compare with RHS const should merge debug locations 2016-12-14 20:27:22 +00:00
Examples
ExecutionEngine
Feature
FileCheck
Instrumentation [asan] Don't skip instrumentation of masked load/store unless we've seen a full load/store on that pointer. 2016-12-14 21:57:04 +00:00
Integer
JitListener
LibDriver LibDriver: Reject inputs that are not COFF objects or bitcode files. 2016-12-14 22:19:22 +00:00
Linker
LTO [LTO] Add the missing datalayout in a test. 2016-12-14 21:57:14 +00:00
MC AMDGPU: Change vintrp printing 2016-12-14 16:36:12 +00:00
Object Object: Make IRObjectFile own multiple modules and enumerate symbols from all modules. 2016-12-13 20:20:17 +00:00
ObjectYAML [ObjectYAML] Support for DWARF debug_aranges 2016-12-09 00:26:44 +00:00
Other [PM] Further broaden this test's regex as both the CGSCC and Function 2016-12-10 07:59:59 +00:00
SymbolRewriter
TableGen
ThinLTO/X86 [LTO] Reject modules without datalayout. 2016-12-14 21:57:04 +00:00
tools Fix test/tools/lto/hide-linkonce-odr.ll after r289719 2016-12-15 01:31:38 +00:00
Transforms [AVX-512][InstCombine] Add masked scalar FMA intrinsics to SimplifyDemandedVectorElts. 2016-12-15 03:49:45 +00:00
Unit
Verifier [Verifier] Add verification for TBAA metadata 2016-12-11 20:07:15 +00:00
YAMLParser
.clang-format
CMakeLists.txt
lit.cfg lit.cfg: Check value of build config rather than converting to boolean 2016-12-14 17:05:34 +00:00
lit.site.cfg.in Revert gold part of change, just liblto 2016-12-14 16:20:25 +00:00
TestRunner.sh