History log of /art/compiler/optimizing/graph_checker.h
Revision Date Author Comments
19b5021a49285627485675ef31276b8194269600 22-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Forbid HDeoptimize instructions in OSR methods.

Otherwise dominated instructions will assume something that
isn't necessarily correct if coming from the interpreter.

bug:28335959
bug:28249238
bug:28348878
bug:28080135

Contains fix from https://android-review.googlesource.com/#/c/220661/.

(cherry picked from commit 93a18c5d4160f632ecdb92af099574e9c7098c49)

Change-Id: I86c3f9340077caa0a3e3db896e0519e7d38d91a0
f355c3ff08710ac2eba3aac2aacc5e65caa06b4c 30-Mar-2016 Roland Levillain <rpl@google.com> Fix Boolean to integral types conversions.

Bug: 27616343
Change-Id: I050f92045bca1b8b5d6da53547cc617f17be84b1
947eb700bec9e214a72d4747864398dc238da60c 25-Mar-2016 Vladimir Marko <vmarko@google.com> Optimizing: Reduce arena memory used by GraphChecker.

Use member variables to reuse the storage instead of
repeatedly allocating new storage for local variables.

Bug: 27690481
Change-Id: I614db9b8614d585653cfbff62e9cf7d7f0c58810
937e6cd515bbe7ff2f255c8fcd40bf1a575a9a16 22-Mar-2016 Roland Levillain <rpl@google.com> Tighten art::HNeg type constraints on its input.

Ensure art::HNeg is only passed a type having the kind of
its input. For a boolean, byte, short, or char input, it
means HNeg's type should be int.

Bug: 27684275
Change-Id: Ic8442c62090a8ab65590754874a14a0deb7acd8d
f6a35de9eeefb20f6446f1b4815b4dcb0161d09c 21-Mar-2016 Vladimir Marko <vmarko@google.com> Optimizing: Fix register allocator validation memory usage.

Also attribute ArenaBitVector allocations to appropriate
passes. This was used to track down the source of the
excessive memory alloactions.

Bug: 27690481

Change-Id: Ib895984cb7c04e24cbc7abbd8322079bab8ab100
badd826664896d4a9628a5a89b78016894aa414b 02-Feb-2016 David Brazdil <dbrazdil@google.com> ART: Run SsaBuilder from HGraphBuilder

First step towards merging the two passes, which will later result in
HGraphBuilder directly producing SSA form. This CL mostly just updates
tests broken by not being able to inspect the pre-SSA form.

Using HLocals outside the HGraphBuilder is now deprecated.

Bug: 27150508
Change-Id: I00fb6050580f409dcc5aa5b5aa3a536d6e8d759e
74eb1b264691c4eb399d0858015a7fc13c476ac6 14-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Implement HSelect

This patch adds a new HIR instruction to Optimizing. HSelect returns
one of two inputs based on the outcome of a condition.

This is only initial implementation which:
- defines the new instruction,
- repurposes BooleanSimplifier to emit it,
- extends InstructionSimplifier to statically resolve it,
- updates existing code and tests accordingly.

Code generators currently emit fallback if/then/else code and will be
updated in follow-up CLs to use platform-specific conditional moves
when possible.

Change-Id: Ib61b17146487ebe6b55350c2b589f0b971dcaaee
f555258861aea7df8af9c2241ab761227fd2f66a 27-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Create BoundType for CheckCast early

ReferenceTypePropagation creates a BoundType for each CheckCast and
replaces all dominated uses of the casted object with it. This does
not include Phi uses on the boundary of the dominated scope, reducing
typing precision. This patch creates the BoundType in Builder, causing
SsaBuilder to replace uses of the object automatically.

Bug: 26081304

Change-Id: I083979155cccb348071ff58cb9060a896ed7d2ac
9bc436160b4af99067973affb0b1008de9a2b04c 05-Nov-2015 David Brazdil <dbrazdil@google.com> ART: Fix simplification of catch blocks in the presence of dead code

Simplification of catch blocks transforms the code so that catch
blocks have only exceptional predecessors. However, it is invoked
before trivially dead code is eliminated which breaks simple
assumptions such as the fact that a catch block cannot start with
move-exception if it has non-exceptional predecessors. This patch
fixes the algorithm to work under these relaxed conditions.

Bug: 25494450
Bug: 25492628
Change-Id: Idc8d010102a4b8b9a6cd918b98d6e11d1838db0c
655e585073ac271cc9afa7c9d6ff5ab4dbe4b72e 12-Oct-2015 Vladimir Marko <vmarko@google.com> Optimizing: Move GraphChecker memory allocations to arena.

Bug: 18120045
Change-Id: I3934158e6ea4868d9baa1dfcc53b603ca6c521e2
fe57faa2e0349418dda38e77ef1c0ac29db75f4d 18-Sep-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Add basic PackedSwitch support

Add HPackedSwitch, and generate it from the builder. Code generators
convert this to a series of compare/branch tests. Better implementation
in the code generators as a real jump table will follow as separate CLs.

Change-Id: If14736fa4d62809b6ae95280148c55682e856911
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
ffee3d33f3ea39aa6031c3d2ff29c4806c8dcc51 06-Jul-2015 David Brazdil <dbrazdil@google.com> ART: Build SSA form when try/catch is present

This patch implements support for try/catch in the SsaBuilder.
Values of locals are propagated from throwing sites inside try
blocks to their respective catch blocks and phis ("catch phis")
are created when necessary.

Change-Id: I0736565c2c4ff3f9f0924b6e3a785a50023f875a
b7a4790e5a2884e62f6dc85aca1455b145e2a7db 29-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Do not update the type of something we already know.""

This reverts commit 63107a804ce17db9789051e1fe310d99d1dae1cb.

bug:22116987

(cherry picked from commit f9a199571417b5a5a62d94d05a064077e14dd2c4)

Change-Id: Ia516f2cbce6d22df37f3a0854abdd0b54d3ea72d
f9a199571417b5a5a62d94d05a064077e14dd2c4 29-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Do not update the type of something we already know.""

This reverts commit 63107a804ce17db9789051e1fe310d99d1dae1cb.

bug:22116987
Change-Id: I49a376a5bd2073a69babe122ec0d26e5d2f82461
63107a804ce17db9789051e1fe310d99d1dae1cb 29-Jun-2015 Calin Juravle <calin@google.com> Revert "Do not update the type of something we already know."

This reverts commit 30eb58c548bee08468f68eb140a74a51dd7d9b43.

Change-Id: Icd959e868160fc3ee7031dd2927554ac5b21d40f
30eb58c548bee08468f68eb140a74a51dd7d9b43 29-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Do not update the type of something we already know.

This is both an optimization to avoid unneeded nodes,
and correctness to avoid replacing the second input
of `HInstanceOf` and `HCheckCast` to something that is
not `HLoadClass`.

bug:22116987

Change-Id: I4907197a9002883d7cae8265a9642512b6201396
fc6a86ab2b70781e72b807c1798b83829ca7f931 26-Jun-2015 David Brazdil <dbrazdil@google.com> Revert "Revert "ART: Implement try/catch blocks in Builder""

This patch enables the GraphBuilder to generate blocks and edges which
represent the exceptional control flow when try/catch blocks are
present in the code. Actual compilation is still delegated to Quick
and Baseline ignores the additional code.

To represent the relationship between try and catch blocks, Builder
splits the edges which enter/exit a try block and links the newly
created blocks to the corresponding exception handlers. This layout
will later enable the SsaBuilder to correctly infer the dominators of
the catch blocks and to produce the appropriate reverse post ordering.
It will not, however, allow for building the complete SSA form of the
catch blocks and consequently optimizing such blocks.

To this end, a new TryBoundary control-flow instruction is introduced.
Codegen treats it the same as a Goto but it allows for additional
successors (the handlers).

This reverts commit 3e18738bd338e9f8363b26bc895f38c0ec682824.

Change-Id: I4f5ea961848a0b83d8db3673763861633e9bfcfb
3e18738bd338e9f8363b26bc895f38c0ec682824 26-Jun-2015 David Brazdil <dbrazdil@google.com> Revert "ART: Implement try/catch blocks in Builder"

Causes OutOfMemory issues, need to investigate.

This reverts commit 0b5c7d1994b76090afcc825e737f2b8c546da2f8.

Change-Id: I263e6cc4df5f9a56ad2ce44e18932ca51d7e349f
0b5c7d1994b76090afcc825e737f2b8c546da2f8 11-Jun-2015 David Brazdil <dbrazdil@google.com> ART: Implement try/catch blocks in Builder

This patch enables the GraphBuilder to generate blocks and edges which
represent the exceptional control flow when try/catch blocks are
present in the code. Actual compilation is still delegated to Quick
and Baseline ignores the additional code.

To represent the relationship between try and catch blocks, Builder
splits the edges which enter/exit a try block and links the newly
created blocks to the corresponding exception handlers. This layout
will later enable the SsaBuilder to correctly infer the dominators of
the catch blocks and to produce the appropriate reverse post ordering.
It will not, however, allow for building the complete SSA form of the
catch blocks and consequently optimizing such blocks.

To this end, a new TryBoundary control-flow instruction is introduced.
Codegen treats it the same as a Goto but it allows for additional
successors (the handlers).

Change-Id: I415b985596d5bebb7b1bb358a46e08b7b04bb53a
1152c926076a760490085c4497c3f117fa8da891 24-Apr-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Rename HasArrayAccesses and check it

Since the flag is only used to see if there is a HBoundsCheck, rename
HasArrayAccesses() to HasBoundsChecks().

Add a check in graph_checker to see that the flag is set if we see a
HBoundsCheck instruction.

Change-Id: I10fe92897374fb247082152dd75c3611cc40ff30
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
4c0eb42259d790fddcd9978b66328dbb3ab65615 24-Apr-2015 Roland Levillain <rpl@google.com> Ensure inlined static calls perform clinit checks in Optimizing.

Calls to static methods have implicit class initialization
(clinit) checks of the method's declaring class in
Optimizing. However, when such a static call is inlined,
the implicit clinit check vanishes, possibly leading to an
incorrect behavior.

To ensure that inlining static methods does not change the
behavior of a program, add explicit class initialization
checks (art::HClinitCheck) as well as load class
instructions (art::HLoadClass) as last input of static
calls (art::HInvokeStaticOrDirect) in Optimizing' control
flow graphs, when the declaring class is reachable and not
known to be already initialized. Then when considering the
inlining of a static method call, proceed only if the method
has no implicit clinit check requirement.

The added explicit clinit checks are already removed by the
art::PrepareForRegisterAllocation visitor. This CL also
extends this visitor to turn explicit clinit checks from
static invokes into implicit ones after the inlining step,
by removing the added art::HLoadClass nodes mentioned
hereinbefore.

Change-Id: I9ba452b8bd09ae1fdd9a3797ef556e3e7e19c651
a4f8831d6533e4fe5aed18433099e1130d95a877 16-Apr-2015 Calin Juravle <calin@google.com> Remove duplicates phis created during SSA transformation

When creating equivalent phis we copy the inputs of the original phi
which may be improperly typed. This will be fixed during the type
propagation but as a result we may have two equivalent phis with the
same type for the same dex register. This is correct but generates more
code and prevent some optimizations.

This CL adds another step in the SSA builder to remove the extra Phi
nodes created due to equality operators.

The graph checker verifies that for a given dex register not two phis
have the same type.

Also, replace zero int constant with null constant when we compare a
reference against null.

Change-Id: Id37cc11a016ea767c7e351575e003d822a9d2e60
13b4718ecd52a674b25eac106e654d8e89872750 15-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Remove DCHECKs for boolean type

Since bool and int are interchangeable types, checking whether an
input is kPrimBoolean can fail when replaced with 0/1 constant or
a phi. This patch removes the problematic DCHECKs, adds a best-effort
verification into SSAChecker but leaves the phi case empty until a
suitable analysis is implemented.

Change-Id: I31e8daf27dd33d2fd74049b82bed1cb7c240c8c6
8d5b8b295930aaa43255c4f0b74ece3ee8b43a47 24-Mar-2015 David Brazdil <dbrazdil@google.com> ART: Force constants into the entry block

Optimizations such as GVN and BCE make the assumption that all
constants are located in the entry block of the CFG, but not all
passes adhere to this rule.

This patch makes constructors of constants private and only accessible
to friend classes - HGraph for int/long constants and SsaBuilder for
float/double - which ensure that they are placed correctly and not
duplicated.

Note that the ArenaAllocatorAdapter was modified to not increment
the ArenaAllocator's internal reference counter in order to allow
for use of ArenaSafeMap inside an arena-allocated objects. Because
their destructor is not called, the counter does not get decremented.

Change-Id: I36a4fa29ae34fb905cdefd482ccbf386cff14166
5c4405e8ca4a0c1ee2d7759e650530c9aff77fd0 21-Jan-2015 Roland Levillain <rpl@google.com> Improve error messages in art::GraphChecker and art::SSAChecker

- Add an art::GraphChecker::AddError helper.
- Use StringPrintf instead of std::stringstream.
- Rephrase some error messages.

Change-Id: Ia741e9e67cb5122f086a7383a2bc02d60ca637df
9ee66183d8e046ea661f642ba884626f16b46e06 16-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Constant fold after inlining.

- Inlining opens up new opportunities for constant folding.
- Fix a bug in constant folder where the result type was not
correctly set for the folding of a HCompare.
- Improve graph checker's coverage.

Change-Id: I0943bf8ff65505c4addc4a555a526b55e00b5268
7c5367badfe61b96c5836d495d286cee64861579 17-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Fix ids and remove invoke when inlining.

Bugs found by Razvan Lupusoru.

Change-Id: I3a5a9af280d8700d18f52abb4a2cff0e3a9aac74
3159674c0863f53cfbc1913d493550221ac47f02 24-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in the type analysis phase of optimizing.

Dex code can lead to the creation of a phi with one
float input and one integer input. Since the SSA builder trusts
the verifier, it assumes that the integer input must be converted
to float. However, when the register is not used afterwards, the
verifier hasn't ensured that. Therefore, the compiler must remove
the phi prior to doing type propagation.

Change-Id: Idcd51c4dccce827c59d1f2b253bc1c919bc07df5
91356c028022180dfbe54ed7f5f465041c8b23ff 07-Nov-2014 Andreas Gampe <agampe@google.com> ART: Use std::vector in GraphChecker

(Temporarily) move GraphChecker to use std::vector for errors, as
std::strings need to be destructed.

Bug: 18120045
Change-Id: I7d38001e6b1f3cee14299194d4515b985541d656
c7dd295a4e0cc1d15c0c96088e55a85389bade74 22-Oct-2014 Ian Rogers <irogers@google.com> Tidy up logging.

Move gVerboseMethods to CompilerOptions. Now "--verbose-methods=" option to
dex2oat rather than runtime argument "-verbose-methods:".
Move ToStr and Dumpable out of logging.h, move LogMessageData into logging.cc
except for a forward declaration.
Remove ConstDumpable as Dump methods are all const (and make this so if not
currently true).
Make LogSeverity an enum and improve compile time assertions and type checking.
Remove log_severity.h that's only used in logging.h.
With system headers gone from logging.h, go add to .cc files missing system
header includes.
Also, make operator new in ValueObject private for compile time instantiation
checking.

Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
75be28332b278cff9039b54bfb228ac72f539ccc 17-Oct-2014 Roland Levillain <rpl@google.com> Revert "Revert "Introduce a class to implement optimization passes.""

This reverts commit 1ddbf6d4b37979a9f11a203c12befd5ae8b65df4.

Change-Id: I110a14668d1564ee0604dc958b91394b40da89fc
633021e6ff6b9a57a374a994e74cfd69275ce100 01-Oct-2014 Roland Levillain <rpl@google.com> Implement default traversals in CFG & SSA graph checkers.

- Check CFG graphs using an insertion order traversal.
- Check SSA form graphs using a reverse post-order traversal.

Change-Id: Ib9062599bdbf3c17b9f213b743274b2d71a9fa90
1ddbf6d4b37979a9f11a203c12befd5ae8b65df4 01-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Introduce a class to implement optimization passes."

This reverts commit bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.

Change-Id: I0a483446666c9c24c45925a5fc199debdefd8b3e
bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8 30-Sep-2014 Roland Levillain <rpl@google.com> Introduce a class to implement optimization passes.

- Add art::HOptimization.
- Rename art::ConstantPropagation to art::HConstantFolding in
compiler/optimizing/constant_folding.h to avoid name
clashes with a class of the same name in
compiler/dex/post_opt_passes.h.
- Rename art::DeadCodeElimination to
art::HDeadCodeElimination for consistency reasons.
- Have art::HDeadCodeElimination and art::HConstantFolding
derive from art::HOptimization.
- Start to use these optimizations in
art:OptimizingCompiler::TryCompile.

Change-Id: Iaab350c122d87b2333b3760312b15c0592d7e010
6b879ddc0959df1cec871f0d41f11cce35a11716 22-Sep-2014 Roland Levillain <rpl@google.com> Add loop- and phi-related checks in the optimizing compiler.

- Ensure the pre-header block is first in the list of
predecessors of a loop header.
- Ensure the loop header has only two predecessors and that
only the second one is the back edge.
- Ensure there is only one back edge per loop.
- Ensure the first input of a phi is not itself.
- Ensure the number of phi inputs is the same as the number
of its predecessors.
- Ensure phi input at index I either comes from the Ith
predecessor or from a block that dominates this
predecessor.

Change-Id: I4db5c68cfbc9b74d2d03125753d0143ece625378
ccc07a9579c554443cd03a306ca9b4f943fd2a93 16-Sep-2014 Roland Levillain <rpl@google.com> Add CFG and SSA form checkers in the optimizing compiler.

Checks performed on control-flow graphs:
- Ensure that the predecessors and successors of a basic block are
consistent within a control-flow graph.
- Ensure basic blocks end with a branch instruction.
- Detect phi functions listed in non-phi instruction lists and vice
versa.
- Ensure a block's instructions (and phi functions) are associated
with this very block.

Checks performed on SSA form graphs:
- Ensure an instruction dominates all its uses.
- Ensure there are no critical edges.

Change-Id: I1c12b4a61ecf608682152c897980ababa7eca847