21 Commits

Author SHA1 Message Date
Hiroshi Yamauchi
63cc4672d3 [PGO][CHR] Speed up following long, interlinked use-def chains.
Summary:
Avoid visiting an instruction more than once by using a map.

This is similar to https://reviews.llvm.org/rL361416.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371086 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-05 16:56:55 +00:00
Jonas Devlieghere
114087caa6 [llvm] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369013 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-15 15:54:37 +00:00
Roman Lebedev
5ae3769ae0 [IR] SelectInst: add swapValues() utility
Summary:
Sometimes we need to swap true-val and false-val of a `SelectInst`.
Having a function for that is nicer than hand-writing it each time.

Reviewers: spatel, RKSimon, craig.topper, jdoerfert

Reviewed By: jdoerfert

Subscribers: jdoerfert, hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367547 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-01 12:31:35 +00:00
Hiroshi Yamauchi
7b98fc0e46 [PGO][CHR] Speed up following long use-def chains.
Summary: Avoid visiting an instruction more than once by using a map.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361416 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-22 18:37:34 +00:00
Hiroshi Yamauchi
ff700028d6 [PGO][CHR] A bug fix.
Summary: Fix a transformation bug where two scopes share a common instrution to hoist.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359736 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-01 22:49:52 +00:00
Fangrui Song
46622a5909 Use llvm::stable_sort
While touching the code, simplify if feasible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358996 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-23 14:51:27 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Vedant Kumar
85aede46d5 [ProfileSummary] Standardize methods and fix comment
Every Analysis pass has a get method that returns a reference of the Result of
the Analysis, for example, BlockFrequencyInfo
&BlockFrequencyInfoWrapperPass::getBFI().  I believe that
ProfileSummaryInfo::getPSI() is the only exception to that, as it was returning
a pointer.

Another change is renaming isHotBB and isColdBB to isHotBlock and isColdBlock,
respectively.  Most methods use BB as the argument of variable names while
methods usually refer to Basic Blocks as Blocks, instead of BB.  For example,
Function::getEntryBlock, Loop:getExitBlock, etc.

I also fixed one of the comments.

Patch by Rodrigo Caetano Rocha!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347182 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 05:23:16 +00:00
Fangrui Song
53a62241d3 Use llvm::copy. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347126 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-17 01:44:25 +00:00
Benjamin Kramer
3898e47d1e Move some helpers from the global namespace into anonymous ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344468 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-13 22:18:22 +00:00
Hiroshi Yamauchi
f65d102fee [PGO][CHR] Add opt remarks.
Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342495 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 16:50:10 +00:00
Fangrui Song
33d40b3195 [PGO] Fix some style issue of ControlHeightReduction
Reviewers: yamauchi

Reviewed By: yamauchi

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341702 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 20:23:15 +00:00
Hiroshi Yamauchi
96a04e655c [PGO][CHR] Build/warning fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341692 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 18:44:53 +00:00
Hiroshi Yamauchi
66f1f168e0 [PGO][CHR] Small cleanup.
Summary:
Do away with demangling. It wasn't really necessary.
Declared some local functions to be static.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341681 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 18:00:58 +00:00
Benjamin Kramer
559403cc05 [ControlHeightReduction] Remove unused includes
Also clang-format them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341468 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05 13:51:05 +00:00
Richard Trieu
8ca386371e Prevent unsigned overflow.
The sum of the weights is caculated in an APInt, which has a width smaller than
64.  In certain cases, the sum of the widths would overflow when calculations
are done inside an APInt, but would not if done with uint64_t.  Since the
values will be passed as uint64_t in the function call anyways, do all the math
in 64 bits.  Also added an assert in case the probabilities overflow 64 bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341444 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05 04:19:15 +00:00
Fangrui Song
ea500dcb7b Fix -Wunused-function in release build after rL341386
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341443 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05 03:10:20 +00:00
Hiroshi Yamauchi
66ded417a2 Fix a memory leak after rL341386.
Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341412 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-04 21:28:22 +00:00
Reid Kleckner
801cfc82da Fix unused variable warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341400 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-04 20:34:47 +00:00
Hiroshi Yamauchi
012ff47f2f Fix build failures after rL341386.
Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341391 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-04 18:10:54 +00:00
Hiroshi Yamauchi
c38c85037d [PGO] Control Height Reduction
Summary:
Control height reduction merges conditional blocks of code and reduces the
number of conditional branches in the hot path based on profiles.

if (hot_cond1) { // Likely true.
  do_stg_hot1();
}
if (hot_cond2) { // Likely true.
  do_stg_hot2();
}

->

if (hot_cond1 && hot_cond2) { // Hot path.
  do_stg_hot1();
  do_stg_hot2();
} else { // Cold path.
  if (hot_cond1) {
    do_stg_hot1();
  }
  if (hot_cond2) {
    do_stg_hot2();
  }
}

This speeds up some internal benchmarks up to ~30%.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: xbolva00, dmgreen, mehdi_amini, llvm-commits, mgorny

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341386 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-04 17:19:13 +00:00