[PATCH] [PBQP] Composable constraints.

David Blaikie dblaikie at gmail.com
Wed Oct 8 13:31:19 PDT 2014


Awesome - much more legible. There's a bunch of changes you can/should
probably just commit as trivial (moving the PBQP namespace inside the llvm
namespace, etc)

* Unfortunately defaulted and deleted functions are not supported by
MSVC2012, so you'll have to write those out explicitly (or rely on the
implicit defaults where you can - MSVC2012 also doesn't generate implicit
move operations, unfortunately... ). For deleted functions you can make
them private and use LLVM_DELETED_FUNCTION or whatever it's called, which
is = delete on compilers that support it, and nothing otherwise (so you get
better diagnostics where available, and a link error otherwise)
* Have you considered the Rule of Zero
<http://flamingdangerzone.com/cxx11/2012/08/15/rule-of-zero.html>?
(granted, doesn't work so well in MSVC2012 where default move operations
are not provided implicitly... )

-        Nodes[NId] = std::move(N);
+        Nodes.emplace(Nodes.begin() + NId, std::move(N));

* You've changed a "modify the existing element" to an "insert an element"
- I assume that part was intentional?
* I'd recommend using insert, rather than emplace here, as emplace doesn't
add any value - insert will do the move operation just fine. You only need
to use emplace when you need to perform an explicit conversion (eg: you
could pass in a raw pointer to emplace of a vector of unique_ptrs and it
would do the right thing). Much like the discussion we've had previously
about "unique_ptr u(x());" versus "unique_ptr u = x();" - avoiding code
that can invoke explicit conversions tends to make it easier to read
because the user doesn't have to be careful that explicit conversions
(which are more powerful, possibly more dangerous) are happening.

* Excess indentation in PBQPRAConstraint.h - we don't generally indent
inside namespaces, right? (indeed your previous change was removing a bunch
of that indentation in other files) Try running clang-format over the
change? (we have a script for that that'll run clang-format over a patch or
over a revision range in git, etc)

* An overriden inline virtual dtor (~PBQPRAConstraintSet) is the default -
you can just omit it. (though the LLVM style guide says that any type with
a vtable should have an anchor function
<http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers>
)

* SpillCosts could just be a struct (since it inherits publicly and all its
members are public)
* blank line at the start of SpillCosts::apply seems strange/out of place

CostMat[I + 1][J + 1] += -Benefit;

Isn't that the same as "-= Benefit" ?

+  std::unique_ptr<Spiller> VRegSpiller =
+    std::unique_ptr<Spiller>(createInlineSpiller(*this, MF, VRM));

A strange piece of code... - I'd omit the std::unique_ptr on the RHS and
just use "unique_ptr VRegSpiller(createInlineSpiller(...))" but ideally,
createInlineSpiller should be returning unique_ptr and then "auto
VRegSpiller = createInlineSpiller(...);"

+    std::unique_ptr<PBQPRAConstraintSet> ConstraintsRoot =
+      llvm::make_unique<PBQPRAConstraintSet>();

Up to you, but usually if I'm using make_unique<T> on the RHS, I just use
auto on the LHS - the type's already clear from the RHS & doesn't bear
repeating.

+        std::string GraphFileName(FullyQualifiedName + "." + RS.str() +
+                                  ".pbqpgraph");

Prefer copy/move initialization (T t = u;) from direct initialization (T
t(u);) where possible.

* createPBQPRegisterAllocator - return by unique_ptr?

-      PBQP::Matrix costs(g.getEdgeCosts(edge));
+      PBQP::Matrix costs(G.getEdgeCosts(edge));

Copy/move init rather than direct init? (I assume getEdgeCosts returns a
PBQP::Matrix, not some other type that's convertible to one)

-      g.setEdgeCosts(edge, costs);
+      G.setEdgeCosts(edge, costs);

std::move(costs)? You've got similar move usage elsewhere, so I assume
that's desired.

-    RegisterRegAlloc::setDefault(createAArch64A57PBQPRegAlloc);
+    RegisterRegAlloc::setDefault(createDefaultPBQPRegisterAllocator);

Isn't that already the default? Do you need to set it again?




On Wed, Oct 8, 2014 at 11:32 AM, Lang Hames <lhames at gmail.com> wrote:

> Hi Dave,
>
> Mostly cleaned up patch attached. There are still a few formatting
> changes, but almost exclusively in places where there are also functional
> changes.
>
> Hope this helps.
>
> - Lang.
>
>
> On Wed, Oct 8, 2014 at 10:08 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Reformatting makes this patch a bit hard to follow - perhaps you could
>> submit a separate reformat & then rebase the patch for easier review? (or
>> at least when it's committed, so the revision history is a bit easier to
>> follow)
>>
>> Yeah, I can't really make heads or tails of which bits of this have
>> semantic changes.
>>
>> On Tue, Oct 7, 2014 at 9:05 PM, Lang Hames <lhames at gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> This patch removes the PBQPBuilder class and its subclasses and replaces
>>> them with a composable constraints class: PBQPRAConstraint. This allows
>>> constraints that are only required for optimisation (e.g. coalescing, soft
>>> pairing) to be mixed and matched. It also makes it easy for targets to
>>> supply custom constraints.
>>>
>>> Most of this patch is PBQP-implementation nitty-gritty, but there's one
>>> part that I'd like some general feedback on: To enable targets to supply
>>> custom constraints I have added a new method to TargetRegisterInfo:
>>>
>>> virtual std::unique_ptr<PBQPRAConstraints> getCustomPBQPConstraints()
>>> const;
>>>
>>> By default this returns a nullptr (indicating no custom constraints are
>>> to be used). TargetRegisterInfo seems like a reasonable place to have this,
>>> but if I've missed a more appropriate spot it would be good to know. (E.g.
>>> If we want to keep TargetRegisterInfo, as much as possible, as an interface
>>> for querying the target about the register file then perhaps it would make
>>> more sense to put this in TargetSubtargetInfo, but the policy in this area
>>> isn't clear to me).
>>>
>>> On the assumption that TargetRegisterInfo is the right place for the
>>> aforementioned method, AArch64 has been updated to override this to supply
>>> its custom constraints. Arnaud - I'd appreciate it if you could take a
>>> quick look and let me know whether you're happy with these AArch64 changes.
>>>
>>> This patch should have no impact on allocation quality, and in almost
>>> all cases I would expect the resulting allocations to be identical. The
>>> only caveat is that PBQP uses FP, and this patch may slightly alter the
>>> order of FP operations during initialisation, which could alter some
>>> allocations. I would expect that to be very rare, if it happens at all.
>>>
>>> Cheers,
>>> Lang.
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141008/2bc4b72f/attachment.html>


More information about the llvm-commits mailing list