1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/unittests
Roman Lebedev 98c29f8197 [PatternMatch] Stabilize the matching order of commutative matchers
Summary:
Currently, we
1. match `LHS` matcher to the `first` operand of binary operator,
2. and then match `RHS` matcher to the `second` operand of binary operator.
If that does not match, we swap the `LHS` and `RHS` matchers:
1. match `RHS` matcher to the `first` operand of binary operator,
2. and then match `LHS` matcher to the `second` operand of binary operator.

This works ok.
But it complicates writing of commutative matchers, where one would like to match
(`m_Value()`) the value on one side, and use (`m_Specific()`) it on the other side.

This is additionally complicated by the fact that `m_Specific()` stores the `Value *`,
not `Value **`, so it won't work at all out of the box.

The last problem is trivially solved by adding a new `m_c_Specific()` that stores the
`Value **`, not `Value *`. I'm choosing to add a new matcher, not change the existing
one because i guess all the current users are ok with existing behavior,
and this additional pointer indirection may have performance drawbacks.
Also, i'm storing pointer, not reference, because for some mysterious-to-me reason
it did not work with the reference.

The first one appears trivial, too.
Currently, we
1. match `LHS` matcher to the `first` operand of binary operator,
2. and then match `RHS` matcher to the `second` operand of binary operator.
If that does not match, we swap the ~~`LHS` and `RHS` matchers~~ **operands**:
1. match ~~`RHS`~~ **`LHS`** matcher to the ~~`first`~~ **`second`** operand of binary operator,
2. and then match ~~`LHS`~~ **`RHS`** matcher to the ~~`second`~ **`first`** operand of binary operator.

Surprisingly, `$ ninja check-llvm` still passes with this.
But i expect the bots will disagree..

The motivational unittest is included.
I'd like to use this in D45664.

Reviewers: spatel, craig.topper, arsenm, RKSimon

Reviewed By: craig.topper

Subscribers: xbolva00, wdng, llvm-commits

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

llvm-svn: 331085
2018-04-27 21:23:20 +00:00
..
ADT [ADT] Make filter_iterator support bidirectional iteration 2018-04-25 21:50:09 +00:00
Analysis [unittests] Change std::sort to llvm::sort in response to r327219 2018-04-07 01:29:45 +00:00
AsmParser
BinaryFormat [dwarf] Unify unknown dwarf enum formatting code 2018-03-21 11:46:37 +00:00
Bitcode Pass a reference to a module to the bitcode writer. 2018-02-14 19:11:32 +00:00
CodeGen [CodeGen] Print user-friendly debug locations as MI comments 2018-04-24 11:00:46 +00:00
DebugInfo [ObjectYAML] Add ability for DWARFYAML to calculate DIE lengths 2018-04-20 12:33:49 +00:00
Demangle Fix another bot failure from r329951. 2018-04-13 02:53:26 +00:00
ExecutionEngine Link to AggressiveInstCombine in a few places. Unbreaks build for me. 2018-04-24 08:40:37 +00:00
FuzzMutate [FuzzMutate] Inst deleter doesn't work with PhiNodes 2018-01-25 09:22:18 +00:00
IR [PatternMatch] Stabilize the matching order of commutative matchers 2018-04-27 21:23:20 +00:00
LineEditor
Linker
MC
MI [LiveIntervals] Handle moving up dead partial write 2018-02-26 14:42:13 +00:00
Object
ObjectYAML
Option [Option] For typo '-foo', suggest '--foo' 2018-01-09 19:38:04 +00:00
Passes Fix PluginsTests failure on Windows buildbots by enabling it everywhere 2018-04-25 20:16:24 +00:00
ProfileData [unittests] Change std::sort to llvm::sort in response to r327219 2018-04-07 01:29:45 +00:00
Support [Support/Path] Add more tests and improve failure messages of existing ones 2018-04-24 08:29:20 +00:00
Target
tools Revert r330027: "[llvm-exegesis] re-enable failing tests after r330026." 2018-04-13 15:19:16 +00:00
Transforms Revert "Revert r330403 and r330413." 2018-04-20 13:34:32 +00:00
XRay
CMakeLists.txt [demangler] Add a partial demangling API for LLDB. 2018-04-12 20:41:38 +00:00