24703 Commits

Author SHA1 Message Date
Simon Pilgrim
985808d7ef [DAGCombiner] Handle correctly non-splat power of 2 -1 divisor (PR37119)
The combine added in commit 329525 overlooked the case where one, but not all, of the divisor elements is -1, -1 is the only power of two value for which the sdiv expansion recipe breaks.

Thanks to @zvi for the original patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336048 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-30 12:22:55 +00:00
Jessica Paquette
c549767db5 [MachineOutliner] Add support for target-default outlining.
This adds functionality to the outliner that allows targets to
specify certain functions that should be outlined from by default.

If a target supports default outlining, then it specifies that in
its TargetOptions. In the case that it does, and the user hasn't
specified that they *never* want to outline, the outliner will
be added to the pass pipeline and will run on those default functions.

This is a preliminary patch for turning the outliner on by default
under -Oz for AArch64.

https://reviews.llvm.org/D48776

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336040 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-30 03:56:03 +00:00
Jessica Paquette
d1bf1e8336 [MachineOutliner] Add always and never options to -enable-machine-outliner
This is a recommit of r335887, which was erroneously committed earlier.

To enable the MachineOutliner by default on AArch64, we need to be able to
disable the MachineOutliner and also provide an option to "always" enable the
outliner.

This adds that capability. It allows the user to still use the old
-enable-machine-outliner option, which defaults to "always". This is building
up to allowing the user to specify "always" versus the target default
outlining behaviour.

https://reviews.llvm.org/D48682

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335986 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29 16:12:45 +00:00
Alexey Bataev
6882f03fec [DEBUG_INFO, NVPTX] Do not emit .debug_loc section.
Summary:
.debug_loc section is not supported for NVPTX target. If there is an
object whose location can change during its lifetime, we do not generate
debug location info for this variable.

Reviewers: echristo

Subscribers: jholewinski, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335976 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29 14:23:28 +00:00
Jessica Paquette
519acca334 [MachineOutliner] Never add the outliner in -O0
This is a recommit of r335879.

We shouldn't add the outliner when compiling at -O0 even if
-enable-machine-outliner is passed in. This makes sure that we
don't add it in this case.

This also removes -O0 from the outliner DWARF test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335930 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 21:49:24 +00:00
Martin Storsjo
d628d72dc9 [COFF] Fix constant sharing regression for MinGW
This fixes a regression since SVN r334523, where the object files
built targeting MinGW were rejected by GNU binutils tools. Prior to
that commit, we only put constants in comdat for MSVC configurations.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335918 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 20:28:29 +00:00
Jessica Paquette
d6b8d8c07b [MachineOutliner] Define MachineOutliner support in TargetOptions
Targets should be able to define whether or not they support the outliner
without the outliner being added to the pass pipeline. Before this, the
outliner pass would be added, and ask the target whether or not it supports the
outliner.

After this, it's possible to query the target in TargetPassConfig, before the
outliner pass is created. This ensures that passing -enable-machine-outliner
will not modify the pass pipeline of any target that does not support it.

https://reviews.llvm.org/D48683

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335887 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:45:43 +00:00
Simon Pilgrim
93aa3932e7 [DAGCombiner] Ensure we use the correct CC result type in visitSDIV (REAPPLIED)
We could get away with it for constant folded cases, but not for rL335719.

Thanks to Krzysztof Parzyszek for noticing.

Reapply original commit rL335821 which was reverted at rL335871 due to a WebAssembly bug that was fixed at rL335884.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335886 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:33:41 +00:00
Jessica Paquette
9bc4099b79 Revert "[MachineOutliner] Add always and never options to -enable-machine-outliner"
I accidentally committed this instead of D48683 because I haven't had coffee
yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335883 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:26:19 +00:00
Jessica Paquette
be2cdf90a3 Revert "[MachineOutliner] Never add the outliner in -O0"
This reverts commit 9c7c10e4073a0bc6a759ce5cd33afbac74930091.

It relies on r335872 since that introduces the machine outliner
flags test. I meant to commit D48683 in that commit, but got mixed
up and committed D48682 instead. So, I'm reverting this and
r335872, since D48682 hasn't made it through review yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335882 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:26:18 +00:00
Jessica Paquette
9c7c10e407 [MachineOutliner] Never add the outliner in -O0
We shouldn't add the outliner when compiling at -O0 even if
-enable-machine-outliner is passed in. This makes sure that we
don't add it in this case.

This also updates machine-outliner-flags to reflect the change
and improves the comment describing what that test does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335879 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:05:57 +00:00
Matthias Braun
294ff667fe SelectionDAGBuilder, mach-o: Skip trap after noreturn call (for Mach-O)
Add NoTrapAfterNoreturn target option which skips emission of traps
behind noreturn calls even if TrapUnreachable is enabled.

Enable the feature on Mach-O to save code size; Comments suggest it is
not possible to enable it for the other users of TrapUnreachable.

rdar://41530228

DifferentialRevision: https://reviews.llvm.org/D48674

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335877 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 17:00:45 +00:00
Jessica Paquette
bd0a2a58e5 [MachineOutliner] Add always and never options to -enable-machine-outliner
To enable the MachineOutliner by default on AArch64, we need to be able to
disable the MachineOutliner and also provide an option to "always" enable the
outliner.

This adds that capability. It allows the user to still use the old
-enable-machine-outliner option, which defaults to "always". This is building
up to allowing the user to specify "always" versus the target-default
outlining behaviour.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335872 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 16:39:42 +00:00
Haojian Wu
5ed53954fb Revert "[DAGCombiner] Ensure we use the correct CC result type in visitSDIV"
This reverts commit r335821.

This crashes the webassembly test, run "ninja check-llvm-codegen-webassembly" to reproduce.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335871 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 16:25:57 +00:00
Benjamin Kramer
1bbef2cc89 Revert "Add support for generating a call graph profile from Branch Frequency Info."
This reverts commits r335794 and r335797. Breaks ThinLTO+FDO selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335851 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 13:15:03 +00:00
Simon Pilgrim
5796a8d871 [DAGCombiner] Ensure we use the correct CC result type in visitSDIV
We could get away with it for constant folded cases, but not for rL335719.

Thanks to Krzysztof Parzyszek for noticing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335821 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 09:54:28 +00:00
Simon Pilgrim
5016671ee0 [DAGCombiner] Remove unused variable. NFCI.
Noticed in D45806 review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335817 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 09:29:08 +00:00
Petar Jovanovic
e1714df0ef [DwarfDebug] Remove unused argument (NFC)
Remove unused ByteStreamer argument from function emitDebugLocValue.

Patch by Nikola Prica.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335811 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 04:50:40 +00:00
Michael J. Spencer
71b21d8fcc Add support for generating a call graph profile from Branch Frequency Info.
=== Generating the CG Profile ===

The CGProfile module pass simply gets the block profile count for each BB and scans for call instructions.  For each call instruction it adds an edge from the current function to the called function with the current BB block profile count as the weight.

After scanning all the functions, it generates an appending module flag containing the data. The format looks like:
```
!llvm.module.flags = !{!0}

!0 = !{i32 5, !"CG Profile", !1}
!1 = !{!2, !3, !4} ; List of edges
!2 = !{void ()* @a, void ()* @b, i64 32} ; Edge from a to b with a weight of 32
!3 = !{void (i1)* @freq, void ()* @a, i64 11}
!4 = !{void (i1)* @freq, void ()* @b, i64 20}
```

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335794 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 23:58:08 +00:00
Nirav Dave
f162464ba8 [DAGCombine] Disable TokenFactor simplifications when optnone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335773 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 19:41:25 +00:00
Daniel Sanders
576283c119 [globalisel][legalizer] Add AtomicOrdering to LegalityQuery and use it in AArch64
Now that we have the ability to legalize based on MMO's. Add support for
legalizing based on AtomicOrdering and use it to correct the legalization
of the atomic instructions.

Also extend all() to be a variadic template as this ruleset now requires
3 and 4 argument versions.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335767 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 19:03:21 +00:00
Sanjay Patel
3d6697fe50 [DAGCombiner] restrict (float)((int) f) --> ftrunc with no-signed-zeros
As noted in the D44909 review, the transform from (fptosi+sitofp) to ftrunc 
can produce -0.0 where the original code does not:

#include <stdio.h>
  
int main(int argc) {
  float x;
  x = -0.8 * argc;
  printf("%f\n", (float)((int)x));
  return 0;
}

$ clang -O0 -mavx fp.c ; ./a.out 
0.000000
$ clang -O1 -mavx fp.c ; ./a.out 
-0.000000

Ideally, we'd use IR/node flags to predicate the transform, but the IR parser 
doesn't currently allow fast-math-flags on the cast instructions. So for now, 
just use the function attribute that corresponds to clang's "-fno-signed-zeros" 
option.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335761 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 18:16:40 +00:00
Jessica Paquette
43d4585d61 [MachineOutliner] Don't outline sequences where x16/x17/nzcv are live across
It isn't safe to outline sequences of instructions where x16/x17/nzcv live
across the sequence.

This teaches the outliner to check whether or not a specific canidate has
x16/x17/nzcv live across it and discard the candidate in the case that that is
true.

https://bugs.llvm.org/show_bug.cgi?id=37573
https://reviews.llvm.org/D47655

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335758 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 17:43:27 +00:00
Simon Pilgrim
16742ac8e4 [DAGCombiner] visitSDIV - add special case handling for (sdiv X, 1) -> X in pow2 expansion
For divisor = 1, perform a select of X - reduces scalarisation of simple SDIVs

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335727 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 12:45:31 +00:00
Simon Pilgrim
8a57afce61 [DAGCombiner] visitSDIV - simplify pow2 handling. NFCI.
Use the builtin constant folding of getNode() etc. instead of doing it manually.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335720 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 10:51:55 +00:00
Simon Pilgrim
988e5b9752 [DAGCombiner] Fold SDIV(%X, MIN_SIGNED) -> SELECT(%X == MIN_SIGNED, 1, 0)
Fixes PR37569.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335719 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 10:21:06 +00:00
Simon Pilgrim
1f74921dd7 [DAGCombiner] Don't accept signbit sdiv divisors in sdiv-by-pow2 vector expansion (PR37569)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335717 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 09:41:22 +00:00
Sanjay Patel
95b187a7dd [DAGCombiner] use isBitwiseNot to simplify code; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335652 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 19:46:56 +00:00
Simon Pilgrim
67cc73d7b2 [DAGCombiner] Don't accept -1 sdiv divisors in sdiv-by-pow2 vector expansion (PR37119)
Temporary fix until I've managed to get D45806 updated - both +1 and -1 special cases need to be properly supported.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335637 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:46:51 +00:00
Simon Pilgrim
007404388e [DAGCombiner] Pull out VT bitwidth in visitSDIV. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335617 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 15:39:16 +00:00
Krzysztof Parzyszek
e873939bd3 Silence "unused variable" warning in LiveIntervals.cpp after r335607
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335610 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 14:55:04 +00:00
Krzysztof Parzyszek
2c45bcb399 Account for undef values from predecessors in extendSegmentsToUses
It is legal for a PHI node not to have a live value in a predecessor
as long as the end of the predecessor is jointly dominated by an undef
value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335607 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 14:37:16 +00:00
Vedant Kumar
f1fc2a32d7 [SelectionDAG] Remove debug locations from ConstantSD(FP)Nodes
This removes debug locations from ConstantSDNode and ConstantSDFPNode.

When this kind of node is materialized we no longer create a line table
entry which jumps back to the constant's first point of use. This makes
single-stepping behavior smoother, and it matches the model used by IR,
where Constants have no locations. See this thread for more context:

  http://lists.llvm.org/pipermail/llvm-dev/2018-June/124164.html

I'd like to handle constant BuildVectorSDNodes and to try to eliminate
passing SDLocs to SelectionDAG::getConstant*() in follow-up commits.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335497 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 17:06:18 +00:00
Matt Arsenault
a26c784064 StackSlotColoring: Decide colors per stack ID
I thought I fixed this in r308673, but that fix was
very broken. The assumption that any frame index can be used
in place of another was more widespread than I realized.
Even when stack slot sharing was disabled, this was still
replacing frame index uses with a different ID with a different
stack slot.

Really fix this by doing the coloring per-stack ID, so all of
the coloring logically done in a separate namespace. This is a lot
simpler than trying to figure out how to change the color if
the stack ID is different.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335488 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 16:05:55 +00:00
Krzysztof Parzyszek
ce1c8d90ff Improve handling of COPY instructions with identical value numbers
Testcases provided by Tim Renouf.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335472 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 13:46:41 +00:00
Artur Pilipenko
647fa5f2e6 Revert change 335077 "[InlineSpiller] Fix a crash due to lack of forward progress from remat specifically for STATEPOINT"
This change caused widespread assertion failures in our downstream testing:
lib/CodeGen/LiveInterval.cpp:409: bool llvm::LiveRange::overlapsFrom(const llvm::LiveRange&, llvm::LiveRange::const_iterator) const: Assertion `!empty() && "empty range"' failed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335462 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 12:58:13 +00:00
Simon Pilgrim
c846c8b55e Fix -Wparentheses gcc warning. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335451 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 11:19:05 +00:00
Sanjay Patel
af1e6f153f [DAGCombiner] eliminate setcc bool math when input is low-bit of some value
This patch has the same motivating example as D48466:
define void @foo(i64 %x, i32 %c.0282.in, i32 %d.0280, i32* %ptr0, i32* %ptr1) {
    %c.0282 = and i32 %c.0282.in, 268435455
    %a16 = lshr i64 32508, %x
    %a17 = and i64 %a16, 1
    %tobool = icmp eq i64 %a17, 0
    %. = select i1 %tobool, i32 1, i32 2
    %.286 = select i1 %tobool, i32 27, i32 26
    %shr97 = lshr i32 %c.0282, %.
    %shl98 = shl i32 %c.0282.in, %.286
    %or99 = or i32 %shr97, %shl98
    %shr100 = lshr i32 %d.0280, %.
    %shl101 = shl i32 %d.0280, %.286
    %or102 = or i32 %shr100, %shl101
    store i32 %or99, i32* %ptr0
    store i32 %or102, i32* %ptr1
    ret void
}

...but I'm trying to kill the setcc bool math sooner rather than later.

By matching a larger pattern that includes both the low-bit mask and the trailing add/sub, 
we can create a universally good fold because we always eliminate the condition code 
intermediate value.

Here are Alive proofs for these (currently instcombine folds the 'add' variants, but 
misses the 'sub' patterns):
https://rise4fun.com/Alive/Gsyp

Name: sub of zext cmp mask
  %a = and i8 %x, 1
  %c = icmp eq i8 %a, 0
  %z = zext i1 %c to i32
  %r = sub i32 C1, %z
  =>
  %optional_cast = zext i8 %a to i32
  %r = add i32 %optional_cast, C1-1

Name: add of zext cmp mask
  %a = and i32 %x, 1
  %c = icmp eq i32 %a, 0
  %z = zext i1 %c to i8
  %r = add i8 %z, C1
  =>
  %optional_cast = trunc i32 %a to i8
  %r = sub i8 C1+1, %optional_cast

All of the tests look like improvements or neutral to me. But it is possible that x86 
test+set+bitop is better than what we now show here. I suspect we could do better by 
adding another fold for the 'sub' variants.

We start with select-of-constant in IR in the larger motivating test, so that's why I 
included tests with selects. Proofs for those variants:
https://rise4fun.com/Alive/Bx1

Name: true const is bigger
Pre: C2 == (C1 + 1)
  %a = and i8 %x, 1
  %c = icmp eq i8 %a, 0
  %r = select i1 %c, i64 C2, i64 C1
  =>
  %z = zext i8 %a to i64
  %r = sub i64 C2, %z

Name: false const is bigger
Pre: C2 == (C1 + 1)
  %a = and i8 %x, 1
  %c = icmp eq i8 %a, 0
  %r = select i1 %c, i64 C1, i64 C2
  =>
  %z = zext i8 %a to i64
  %r = add i64 C1, %z

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335433 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-24 14:37:30 +00:00
Krzysztof Parzyszek
d407e550d9 Initialize LiveRegs once in BranchFolder::mergeCommonTails
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 16:38:38 +00:00
George Rimar
af36295232 Recommit r335333 "[MC] - Add .stack_size sections into groups and link them with .text"
With compilation fix.

Original commit message:

D39788 added a '.stack-size' section containing metadata on function stack sizes
to output ELF files behind the new -stack-size-section flag.

This change does following two things on top:

1) Imagine the case when there are -ffunction-sections flag given and there are text sections in COMDATs. 
    The patch adds a '.stack-size' section into corresponding COMDAT group, so that linker will be able to
    eliminate them fast during resolving the COMDATs.
2) Patch sets a SHF_LINK_ORDER flag and links '.stack-size' with the corresponding .text.
   With that linker will be able to do -gc-sections on dead stack sizes sections.

Differential revision: https://reviews.llvm.org/D46874

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335336 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 10:53:47 +00:00
George Rimar
51ddc3757a Revert r335332 "[MC] - Add .stack_size sections into groups and link them with .text"
It broke bots.

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/12891
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/9443
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/25551

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335333 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 10:27:33 +00:00
George Rimar
08d6b0d9f0 [MC] - Add .stack_size sections into groups and link them with .text
D39788 added a '.stack-size' section containing metadata on function stack sizes
to output ELF files behind the new -stack-size-section flag.

This change does following two things on top:

1) Imagine the case when there are -ffunction-sections flag given and there are text sections in COMDATs. 
    The patch adds a '.stack-size' section into corresponding COMDAT group, so that linker will be able to
    eliminate them fast during resolving the COMDATs.
2) Patch sets a SHF_LINK_ORDER flag and links '.stack-size' with the corresponding .text.
   With that linker will be able to do -gc-sections on dead stack sizes sections.

Differential revision: https://reviews.llvm.org/D46874

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335332 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 10:10:53 +00:00
Chandler Carruth
8e0778c059 Revert r335306 (and r335314) - the Call Graph Profile pass.
This is the first pass in the main pipeline to use the legacy PM's
ability to run function analyses "on demand". Unfortunately, it turns
out there are bugs in that somewhat-hacky approach. At the very least,
it leaks memory and doesn't support -debug-pass=Structure. Unclear if
there are larger issues or not, but this should get the sanitizer bots
back to green by fixing the memory leaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335320 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 05:33:57 +00:00
Michael J. Spencer
3499852bee [Instrumentation] Add Call Graph Profile pass
This patch adds support for generating a call graph profile from Branch Frequency Info.

The CGProfile module pass simply gets the block profile count for each BB and scans for call instructions. For each call instruction it adds an edge from the current function to the called function with the current BB block profile count as the weight.

After scanning all the functions, it generates an appending module flag containing the data. The format looks like:

!llvm.module.flags = !{!0}

!0 = !{i32 5, !"CG Profile", !1}
!1 = !{!2, !3, !4} ; List of edges
!2 = !{void ()* @a, void ()* @b, i64 32} ; Edge from a to b with a weight of 32
!3 = !{void (i1)* @freq, void ()* @a, i64 11}
!4 = !{void (i1)* @freq, void ()* @b, i64 20}

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335306 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 23:31:10 +00:00
Reid Kleckner
b9c0a17b9f [X86] Fix 32-bit mingw comdat names, only add one underscore
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335304 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 23:06:33 +00:00
Reid Kleckner
845b439bb4 [mingw] Fix GCC ABI compatibility for comdat things
Summary:
GCC and the binutils COFF linker do comdats differently from MSVC.
If we want to be ABI compatible, we have to do what they do, which is to
emit unique section names like ".text$_Z3foov" instead of short section
names like ".text". Otherwise, the binutils linker gets confused and
reports multiple definition errors when two object files from GCC and
Clang containing the same inline function are linked together.

The best description of the issue is probably at
https://github.com/Alexpux/MINGW-packages/issues/1677, we don't seem to
have a good one in our tracker.

I fixed up the .pdata and .xdata sections needed everywhere other than
32-bit x86. GCC doesn't use associative comdats for those, it appears to
rely on the section name.

Reviewers: smeenai, compnerd, mstorsjo, martell, mati865

Subscribers: llvm-commits, hiraditya

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335286 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 20:27:38 +00:00
Matt Davis
50feec5fc1 [DebugInfo] Ignore DBG_VALUE instructions in PostRA Machine Sink
Summary:
The logic for handling the sinking of COPY instructions was generating
different code when building with debug flags.

The original code did not take into consideration debug instructions.  This
resulted in the registers in the DBG_VALUE instructions being treated as used,
and prevented the COPY from being sunk.  This patch avoids analyzing debug
instructions when trying to sink COPY instructions.

This patch also creates a routine from the code in MachineSinking::SinkInstruction to
perform the logic of sinking an instruction along with its debug instructions.
This functionality is used in multiple places, including the code for sinking COPY instrs.


Reviewers: junbuml, javed.absar, MatzeB, bjope

Reviewed By: bjope

Subscribers: aprantl, probinson, thegameg, jonpa, bjope, vsk, kristof.beyls, JDevlieghere, llvm-commits

Tags: #debug-info

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335264 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 17:59:52 +00:00
Stanislav Mekhanoshin
8f072ac5b4 DAG combine "and|or (select c, -1, 0), x" -> "select c, x, 0|-1"
Allowed folding for "and/or" binops with non-constant operand if
arguments of select are 0/-1 values.

Normally this code with "and" opcode does not get to a DAG combiner
and simplified yet in the InstCombine. However AMDGPU produces it
during lowering and InstCombine has no chance to optimize it out.

In turn the same pattern with "or" opcode can reach DAG.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335250 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 16:02:05 +00:00
Krzysztof Parzyszek
2165044949 [CodeGen] Avoid handling DBG_VALUE in LiveRegUnits::stepBackward
Patch by Jesper Antonsson.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335233 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 13:38:43 +00:00
Mikael Holmen
b16b4ba59a [DebugInfo] Make sure all DBG_VALUEs' reguse operands have IsDebug property
Summary:
In some cases, these operands lacked the IsDebug property, which is meant to signal that
they should not affect codegen. This patch adds a check for this property in the
MachineVerifier and adds it where it was missing.

This includes refactorings to use MachineInstrBuilder construction functions instead of
manually setting up the intrinsic everywhere.

Patch by: JesperAntonsson

Reviewers: aprantl, rnk, echristo, javed.absar

Reviewed By: aprantl

Subscribers: qcolombet, sdardis, nemanjai, JDevlieghere, atanasyan, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 10:03:34 +00:00