Skip to content

Commit f4b2516

Browse files
author
Jenkins
committed
SWDEV-179954 - OpenCL/LC - Merge branch amd-master into amd-common
Change-Id: I4f735e083b9a15145ed6e8ea5720ae0cb21cf4c9
2 parents 1d82813 + f066609 commit f4b2516

File tree

137 files changed

+2256
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+2256
-425
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,3 +1097,7 @@ if (LLVM_INCLUDE_BENCHMARKS)
10971097
add_subdirectory(utils/benchmark)
10981098
add_subdirectory(benchmarks)
10991099
endif()
1100+
1101+
if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
1102+
add_subdirectory(utils/llvm-locstats)
1103+
endif()

cmake/modules/AddSphinxTarget.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ function (add_sphinx_target builder project)
7171
COMPONENT "${project}-sphinx-man"
7272
DESTINATION ${INSTALL_MANDIR}man1)
7373

74+
if(NOT LLVM_ENABLE_IDE)
75+
add_llvm_install_targets("install-${SPHINX_TARGET_NAME}"
76+
DEPENDS ${SPHINX_TARGET_NAME}
77+
COMPONENT "${project}-sphinx-man")
78+
endif()
7479
elseif (builder STREQUAL html)
7580
string(TOUPPER "${project}" project_upper)
7681
set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html"
@@ -82,6 +87,12 @@ function (add_sphinx_target builder project)
8287
install(DIRECTORY "${SPHINX_BUILD_DIR}/."
8388
COMPONENT "${project}-sphinx-html"
8489
DESTINATION "${${project_upper}_INSTALL_SPHINX_HTML_DIR}")
90+
91+
if(NOT LLVM_ENABLE_IDE)
92+
add_llvm_install_targets("install-${SPHINX_TARGET_NAME}"
93+
DEPENDS ${SPHINX_TARGET_NAME}
94+
COMPONENT "${project}-sphinx-html")
95+
endif()
8596
else()
8697
message(WARNING Installation of ${builder} not supported)
8798
endif()

cmake/modules/TableGen.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ macro(add_tablegen target project)
171171

172172
install(TARGETS ${target}
173173
${export_to_llvmexports}
174+
COMPONENT ${target}
174175
RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR})
176+
if(NOT LLVM_ENABLE_IDE)
177+
add_llvm_install_targets("install-${target}"
178+
DEPENDS ${target}
179+
COMPONENT ${target})
180+
endif()
175181
endif()
176182
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
177183
endmacro()

docs/CommandGuide/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ Developer Tools
7474
llvm-build
7575
llvm-exegesis
7676
llvm-pdbutil
77+
llvm-locstats

docs/CommandGuide/llvm-locstats.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
llvm-locstats - calculate statistics on DWARF debug location
2+
============================================================
3+
4+
.. program:: llvm-locstats
5+
6+
SYNOPSIS
7+
--------
8+
9+
:program:`llvm-locstats` [*options*] [*filename*]
10+
11+
DESCRIPTION
12+
-----------
13+
14+
:program:`llvm-locstats` works like a wrapper around :program:`llvm-dwarfdump`.
15+
It parses :program:`llvm-dwarfdump` statistics regarding debug location by
16+
pretty printing it in a more human readable way.
17+
18+
The line 0% shows the number and the percentage of DIEs with no location
19+
information, but the line 100% shows the information for DIEs where there is
20+
location information in all code section bytes (where the variable or parameter
21+
is in the scope). The line 50-59% shows the number and the percentage of DIEs
22+
where the location information is between 50 and 59 percentage of its scope
23+
covered.
24+
25+
OPTIONS
26+
-------
27+
28+
.. option:: -only-variables
29+
30+
Calculate the location statistics only for local variables.
31+
32+
.. option:: -only-formal-parameters
33+
34+
Calculate the location statistics only for formal parameters.
35+
36+
.. option:: -ignore-debug-entry-values
37+
38+
Ignore the location statistics on locations containing the
39+
debug entry values DWARF operation.
40+
41+
EXIT STATUS
42+
-----------
43+
44+
:program:`llvm-locstats` returns 0 if the input file were parsed
45+
successfully. Otherwise, it returns 1.
46+
47+
OUTPUT EXAMPLE
48+
--------------
49+
50+
.. code-block:: none
51+
52+
=================================================
53+
Debug Location Statistics
54+
=================================================
55+
cov% samples percentage(~)
56+
-------------------------------------------------
57+
0% 1 16%
58+
1-9% 0 0%
59+
10-19% 0 0%
60+
20-29% 0 0%
61+
30-39% 0 0%
62+
40-49% 0 0%
63+
50-99% 1 16%
64+
60-69% 0 0%
65+
70-79% 0 0%
66+
80-89% 1 16%
67+
90-99% 0 0%
68+
100% 3 50%
69+
=================================================
70+
-the number of debug variables processed: 6
71+
-PC ranges covered: 81%
72+
-------------------------------------------------
73+
-total availability: 83%
74+
=================================================
75+
76+
SEE ALSO
77+
--------
78+
79+
:manpage:`llvm-dwarfdump(1)`

docs/CommandGuide/llvm-objcopy.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ multiple file formats.
8282
Remove the specified section from the output. Can be specified multiple times
8383
to remove multiple sections simultaneously.
8484

85+
.. option:: --set-section-alignment <section>=<align>
86+
87+
Set the alignment of section ``<section>`` to `<align>``. Can be specified
88+
multiple times to update multiple sections.
89+
8590
.. option:: --strip-all-gnu
8691

8792
Remove all symbols, debug sections and relocations from the output. This option
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//=- MachineLoopUtils.h - Helper functions for manipulating loops -*- C++ -*-=//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_CODEGEN_MACHINELOOPUTILS_H
10+
#define LLVM_LIB_CODEGEN_MACHINELOOPUTILS_H
11+
12+
namespace llvm {
13+
class MachineBasicBlock;
14+
class MachineRegisterInfo;
15+
class TargetInstrInfo;
16+
17+
enum LoopPeelDirection {
18+
LPD_Front, ///< Peel the first iteration of the loop.
19+
LPD_Back ///< Peel the last iteration of the loop.
20+
};
21+
22+
/// Peels a single block loop. Loop must have two successors, one of which
23+
/// must be itself. Similarly it must have two predecessors, one of which must
24+
/// be itself.
25+
///
26+
/// The loop block is copied and inserted into the CFG such that two copies of
27+
/// the loop follow on from each other. The copy is inserted either before or
28+
/// after the loop based on Direction.
29+
///
30+
/// Phis are updated and an unconditional branch inserted at the end of the
31+
/// clone so as to execute a single iteration.
32+
///
33+
/// The trip count of Loop is not updated.
34+
MachineBasicBlock *PeelSingleBlockLoop(LoopPeelDirection Direction,
35+
MachineBasicBlock *Loop,
36+
MachineRegisterInfo &MRI,
37+
const TargetInstrInfo *TII);
38+
39+
} // namespace llvm
40+
41+
#endif // LLVM_LIB_CODEGEN_MACHINELOOPUTILS_H

include/llvm/CodeGen/MachineMemOperand.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ class MachineMemOperand {
293293

294294
/// Support for operator<<.
295295
/// @{
296-
void print(raw_ostream &OS) const;
297-
void print(raw_ostream &OS, ModuleSlotTracker &MST) const;
298296
void print(raw_ostream &OS, ModuleSlotTracker &MST,
299297
SmallVectorImpl<StringRef> &SSNs, const LLVMContext &Context,
300298
const MachineFrameInfo *MFI, const TargetInstrInfo *TII) const;
@@ -319,11 +317,6 @@ class MachineMemOperand {
319317
}
320318
};
321319

322-
inline raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MRO) {
323-
MRO.print(OS);
324-
return OS;
325-
}
326-
327320
} // End llvm namespace
328321

329322
#endif

include/llvm/CodeGen/ModuloSchedule.h

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262

6363
#include "llvm/CodeGen/MachineFunction.h"
6464
#include "llvm/CodeGen/MachineLoopInfo.h"
65+
#include "llvm/CodeGen/MachineLoopUtils.h"
6566
#include "llvm/CodeGen/TargetInstrInfo.h"
6667
#include "llvm/CodeGen/TargetSubtargetInfo.h"
68+
#include <deque>
6769
#include <vector>
6870

6971
namespace llvm {
@@ -142,9 +144,7 @@ class ModuloSchedule {
142144
/// Return the rescheduled instructions in order.
143145
ArrayRef<MachineInstr *> getInstructions() { return ScheduledInstrs; }
144146

145-
void dump() {
146-
print(dbgs());
147-
}
147+
void dump() { print(dbgs()); }
148148
void print(raw_ostream &OS);
149149
};
150150

@@ -270,9 +270,6 @@ class ModuloScheduleExpander {
270270

271271
/// A reimplementation of ModuloScheduleExpander. It works by generating a
272272
/// standalone kernel loop and peeling out the prologs and epilogs.
273-
///
274-
/// FIXME: This implementation cannot yet generate valid code. It can generate
275-
/// a correct kernel but cannot peel out prologs and epilogs.
276273
class PeelingModuloScheduleExpander {
277274
ModuloSchedule &Schedule;
278275
MachineFunction &MF;
@@ -281,17 +278,70 @@ class PeelingModuloScheduleExpander {
281278
const TargetInstrInfo *TII;
282279
LiveIntervals *LIS;
283280

281+
/// The original loop block that gets rewritten in-place.
284282
MachineBasicBlock *BB;
283+
/// The original loop preheader.
285284
MachineBasicBlock *Preheader;
285+
/// All prolog and epilog blocks.
286+
SmallVector<MachineBasicBlock *, 4> Prologs, Epilogs;
287+
/// For every block, the stages that are produced.
288+
DenseMap<MachineBasicBlock *, BitVector> LiveStages;
289+
/// For every block, the stages that are available. A stage can be available
290+
/// but not produced (in the epilog) or produced but not available (in the
291+
/// prolog).
292+
DenseMap<MachineBasicBlock *, BitVector> AvailableStages;
293+
294+
/// CanonicalMIs and BlockMIs form a bidirectional map between any of the
295+
/// loop kernel clones.
296+
DenseMap<MachineInstr *, MachineInstr *> CanonicalMIs;
297+
DenseMap<std::pair<MachineBasicBlock *, MachineInstr *>, MachineInstr *>
298+
BlockMIs;
299+
300+
/// State passed from peelKernel to peelPrologAndEpilogs().
301+
std::deque<MachineBasicBlock *> PeeledFront, PeeledBack;
302+
286303
public:
287304
PeelingModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S,
288305
LiveIntervals *LIS)
289306
: Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
290307
TII(ST.getInstrInfo()), LIS(LIS) {}
291308

309+
void expand();
310+
292311
/// Runs ModuloScheduleExpander and treats it as a golden input to validate
293312
/// aspects of the code generated by PeelingModuloScheduleExpander.
294313
void validateAgainstModuloScheduleExpander();
314+
315+
protected:
316+
/// Converts BB from the original loop body to the rewritten, pipelined
317+
/// steady-state.
318+
void rewriteKernel();
319+
320+
private:
321+
/// Peels one iteration of the rewritten kernel (BB) in the specified
322+
/// direction.
323+
MachineBasicBlock *peelKernel(LoopPeelDirection LPD);
324+
/// Peel the kernel forwards and backwards to produce prologs and epilogs,
325+
/// and stitch them together.
326+
void peelPrologAndEpilogs();
327+
/// All prolog and epilog blocks are clones of the kernel, so any produced
328+
/// register in one block has an corollary in all other blocks.
329+
Register getEquivalentRegisterIn(Register Reg, MachineBasicBlock *BB);
330+
/// Change all users of MI, if MI is predicated out
331+
/// (LiveStages[MI->getParent()] == false).
332+
void rewriteUsesOf(MachineInstr *MI);
333+
/// Insert branches between prologs, kernel and epilogs.
334+
void fixupBranches();
335+
/// Create a poor-man's LCSSA by cloning only the PHIs from the kernel block
336+
/// to a block dominated by all prologs and epilogs. This allows us to treat
337+
/// the loop exiting block as any other kernel clone.
338+
MachineBasicBlock *CreateLCSSAExitingBlock();
339+
/// Helper to get the stage of an instruction in the schedule.
340+
unsigned getStage(MachineInstr *MI) {
341+
if (CanonicalMIs.count(MI))
342+
MI = CanonicalMIs[MI];
343+
return Schedule.getStage(MI);
344+
}
295345
};
296346

297347
/// Expander that simply annotates each scheduled instruction with a post-instr

include/llvm/CodeGen/SwitchLoweringUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,14 @@ struct BitTestBlock {
212212
BitTestInfo Cases;
213213
BranchProbability Prob;
214214
BranchProbability DefaultProb;
215+
bool OmitRangeCheck;
215216

216217
BitTestBlock(APInt F, APInt R, const Value *SV, unsigned Rg, MVT RgVT, bool E,
217218
bool CR, MachineBasicBlock *P, MachineBasicBlock *D,
218219
BitTestInfo C, BranchProbability Pr)
219220
: First(std::move(F)), Range(std::move(R)), SValue(SV), Reg(Rg),
220221
RegVT(RgVT), Emitted(E), ContiguousRange(CR), Parent(P), Default(D),
221-
Cases(std::move(C)), Prob(Pr) {}
222+
Cases(std::move(C)), Prob(Pr), OmitRangeCheck(false) {}
222223
};
223224

224225
/// Return the range of values within a range.

0 commit comments

Comments
 (0)