Skip to content

Commit 2de1778

Browse files
authored
merge main into amd-staging (#431)
2 parents 30ad1e7 + 5dc1547 commit 2de1778

File tree

20 files changed

+605
-30
lines changed

20 files changed

+605
-30
lines changed

clang/tools/clang-shlib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ if (CLANG_LINK_CLANG_DYLIB)
4141
set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
4242
endif()
4343

44+
if (HAIKU)
45+
list(APPEND _DEPS network)
46+
endif()
47+
4448
add_clang_library(clang-cpp
4549
SHARED
4650
${INSTALL_WITH_TOOLCHAIN}

llvm/docs/HowToSubmitABug.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ Introduction - Got bugs?
66
========================
77

88

9-
If you're working with LLVM and run into a bug, we definitely want to know
9+
If you're working with LLVM and encounter a bug, we definitely want to know
1010
about it. This document describes what you can do to increase the odds of
1111
getting it fixed quickly.
1212

1313
🔒 If you believe that the bug is security related, please follow :ref:`report-security-issue`. 🔒
1414

15-
Basically you have to do two things at a minimum. First, decide whether the
15+
Basically, you have to do two things at a minimum. First, decide whether the
1616
bug `crashes the compiler`_ or if the compiler is `miscompiling`_ the program
1717
(i.e., the compiler successfully produces an executable, but it doesn't run
1818
right). Based on what type of bug it is, follow the instructions in the
1919
linked section to narrow down the bug so that the person who fixes it will be
2020
able to find the problem more easily.
2121

22-
Once you have a reduced test-case, go to `the LLVM Bug Tracking System
22+
Once you have a reduced test case, go to `the LLVM Bug Tracking System
2323
<https://github.com/llvm/llvm-project/issues>`_ and fill out the form with the
2424
necessary details (note that you don't need to pick a label, just use if you're
2525
not sure). The bug description should contain the following information:
2626

2727
* All information necessary to reproduce the problem.
28-
* The reduced test-case that triggers the bug.
28+
* The reduced test case that triggers the bug.
2929
* The location where you obtained LLVM (if not from our Git
3030
repository).
3131

@@ -39,10 +39,10 @@ Crashing Bugs
3939
More often than not, bugs in the compiler cause it to crash---often due to
4040
an assertion failure of some sort. The most important piece of the puzzle
4141
is to figure out if it is crashing in the Clang front-end or if it is one of
42-
the LLVM libraries (e.g. the optimizer or code generator) that has
42+
the LLVM libraries (e.g., the optimizer or code generator) that has
4343
problems.
4444

45-
To figure out which component is crashing (the front-end, middle-end
45+
To identify the crashing component (the front-end, middle-end
4646
optimizer, or backend code generator), run the ``clang`` command line as you
4747
were when the crash occurred, but with the following extra command line
4848
options:
@@ -53,7 +53,7 @@ options:
5353
<frontend-crash>`.
5454

5555
* ``-emit-llvm``: If ``clang`` crashes with this option (which disables
56-
the code generator), you found a middle-end optimizer bug. Jump ahead to
56+
the code generator), you've found a middle-end optimizer bug. Jump ahead to
5757
:ref:`middle-end bugs <middleend-crash>`.
5858

5959
* Otherwise, you have a backend code generator crash. Jump ahead to :ref:`code
@@ -102,19 +102,19 @@ functions. Then run:
102102
If this doesn't crash, please follow the instructions for a :ref:`front-end
103103
bug <frontend-crash>`.
104104

105-
If this does crash, then you should be able to debug this with the following
105+
If this does crash, then you can debug this with the following
106106
:doc:`bugpoint <Bugpoint>` command:
107107

108108
.. code-block:: bash
109109
110110
bugpoint foo.bc -O3
111111
112-
Run this, then file a bug with the instructions and reduced .bc
112+
Run this, then file a bug with the instructions and reduced ``.bc``
113113
files that bugpoint emits.
114114

115115
If bugpoint doesn't reproduce the crash,
116116
:doc:`llvm-reduce <CommandGuide/llvm-reduce>` is an alternative way to reduce
117-
LLVM IR. Create a script that repros the crash and run:
117+
LLVM IR. Create a script that reproduces the crash and run:
118118

119119
.. code-block:: bash
120120
@@ -137,26 +137,26 @@ Backend code generator bugs
137137
---------------------------
138138

139139
If you find a bug that crashes clang in the code generator, compile your
140-
source file to a .bc file by passing "``-emit-llvm -c -o foo.bc``" to
141-
clang (in addition to the options you already pass). Once your have
142-
foo.bc, one of the following commands should fail:
140+
source file to a ``.bc`` file by passing "``-emit-llvm -c -o foo.bc``" to
141+
clang (in addition to the options you already pass). Once you have
142+
``foo.bc``, one of the following commands should fail:
143143

144144
#. ``llc foo.bc``
145145
#. ``llc foo.bc -relocation-model=pic``
146146
#. ``llc foo.bc -relocation-model=static``
147147

148148
If none of these crash, please follow the instructions for a :ref:`front-end
149-
bug<frontend-crash>`. If one of these do crash, you should be able to reduce
149+
bug<frontend-crash>`. If one of these crashes, you should be able to reduce
150150
this with one of the following :doc:`bugpoint <Bugpoint>` command lines (use
151151
the one corresponding to the command above that failed):
152152

153153
#. ``bugpoint -run-llc foo.bc``
154154
#. ``bugpoint -run-llc foo.bc --tool-args -relocation-model=pic``
155155
#. ``bugpoint -run-llc foo.bc --tool-args -relocation-model=static``
156156

157-
Please run this, then file a bug with the instructions and reduced .bc file
157+
Please run this, then file a bug with the instructions and reduced ``.bc`` file
158158
that bugpoint emits. If something goes wrong with bugpoint, please submit
159-
the "foo.bc" file and the option that llc crashes with.
159+
the ``foo.bc`` file and the option that llc crashes with.
160160

161161
LTO bugs
162162
---------------------------
@@ -174,7 +174,7 @@ in addition to your existing compilation options:
174174
These options enable LTO and save temporary files generated during compilation
175175
for later analysis.
176176

177-
On Windows, you should be using lld-link as the linker. Adjust your compilation
177+
On Windows, use lld-link as the linker. Adjust your compilation
178178
flags as follows:
179179
* Add ``/lldsavetemps`` to the linker flags.
180180
* When linking from the compiler driver, add ``/link /lldsavetemps`` in order to forward that flag to the linker.
@@ -199,7 +199,7 @@ command line (use the bc file corresponding to the command above that failed):
199199
200200
llvm-reduce --test reduce.sh a.out.0.2.internalize.bc
201201
202-
Example of reduce.sh script
202+
Example of ``reduce.sh`` script
203203

204204
.. code-block:: bash
205205
@@ -209,9 +209,9 @@ Example of reduce.sh script
209209
path/to/not --crash path/to/opt "-passes=lto<O3>" $1 -o temp.bc 2> err.log
210210
grep -q "It->second == &Insn" err.log
211211
212-
Here we have grepped the failed assert message.
212+
Here we have grepped for the failed assert message.
213213

214-
Please run this, then file a bug with the instructions and reduced .bc file
214+
Please run this, then file a bug with the instructions and reduced ``.bc`` file
215215
that llvm-reduce emits.
216216

217217
.. _miscompiling:
@@ -221,16 +221,16 @@ Miscompilations
221221

222222
If clang successfully produces an executable, but that executable doesn't run
223223
right, this is either a bug in the code or a bug in the compiler. The first
224-
thing to check is to make sure it is not using undefined behavior (e.g.
224+
thing to check is to make sure it is not using undefined behavior (e.g.,
225225
reading a variable before it is defined). In particular, check to see if the
226226
program is clean under various `sanitizers
227-
<https://github.com/google/sanitizers>`_ (e.g. ``clang
227+
<https://github.com/google/sanitizers>`_ (e.g., ``clang
228228
-fsanitize=undefined,address``) and `valgrind <http://valgrind.org/>`_. Many
229229
"LLVM bugs" that we have chased down ended up being bugs in the program being
230230
compiled, not LLVM.
231231

232232
Once you determine that the program itself is not buggy, you should choose
233-
which code generator you wish to compile the program with (e.g. LLC or the JIT)
233+
which code generator you wish to compile the program with (e.g., LLC or the JIT)
234234
and optionally a series of LLVM passes to run. For example:
235235

236236
.. code-block:: bash

llvm/lib/MC/MCParser/AsmLexer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/ADT/StringExtras.h"
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/MC/MCAsmInfo.h"
19-
#include "llvm/MC/MCParser/AsmLexer.h"
2019
#include "llvm/Support/Compiler.h"
2120
#include "llvm/Support/SMLoc.h"
2221
#include "llvm/Support/SaveAndRestore.h"

llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ WebAssemblyFrameLowering::getLocalForStackObject(MachineFunction &MF,
8181
// Abuse object size to record number of WebAssembly locals allocated to
8282
// this object.
8383
MFI.setObjectSize(FrameIndex, ValueVTs.size());
84-
return static_cast<unsigned>(Local);
84+
return Local;
8585
}
8686

8787
/// We need a base pointer in the case of having items on the stack that
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===- StructuralTypeConversions.h - CF Type Conversions --------*- 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 MLIR_DIALECT_CONTROL_FLOW_TRANSFORMS_STRUCTURAL_TYPE_CONVERSIONS_H
10+
#define MLIR_DIALECT_CONTROL_FLOW_TRANSFORMS_STRUCTURAL_TYPE_CONVERSIONS_H
11+
12+
#include "mlir/IR/PatternMatch.h"
13+
14+
namespace mlir {
15+
16+
class ConversionTarget;
17+
class TypeConverter;
18+
19+
namespace cf {
20+
21+
/// Populates patterns for CF structural type conversions and sets up the
22+
/// provided ConversionTarget with the appropriate legality configuration for
23+
/// the ops to get converted properly.
24+
///
25+
/// A "structural" type conversion is one where the underlying ops are
26+
/// completely agnostic to the actual types involved and simply need to update
27+
/// their types. An example of this is cf.br -- the cf.br op needs to update
28+
/// its types accordingly to the TypeConverter, but otherwise does not care
29+
/// what type conversions are happening.
30+
void populateCFStructuralTypeConversionsAndLegality(
31+
const TypeConverter &typeConverter, RewritePatternSet &patterns,
32+
ConversionTarget &target, PatternBenefit benefit = 1);
33+
34+
/// Similar to `populateCFStructuralTypeConversionsAndLegality` but does not
35+
/// populate the conversion target.
36+
void populateCFStructuralTypeConversions(const TypeConverter &typeConverter,
37+
RewritePatternSet &patterns,
38+
PatternBenefit benefit = 1);
39+
40+
/// Updates the ConversionTarget with dynamic legality of CF operations based
41+
/// on the provided type converter.
42+
void populateCFStructuralTypeConversionTarget(
43+
const TypeConverter &typeConverter, ConversionTarget &target);
44+
45+
} // namespace cf
46+
} // namespace mlir
47+
48+
#endif // MLIR_DIALECT_CONTROL_FLOW_TRANSFORMS_STRUCTURAL_TYPE_CONVERSIONS_H

mlir/include/mlir/Dialect/OpenACC/Analysis/OpenACCSupport.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
namespace mlir {
5959
namespace acc {
6060

61+
// Forward declaration for RecipeKind enum
62+
enum class RecipeKind : uint32_t;
63+
6164
namespace detail {
6265
/// This class contains internal trait classes used by OpenACCSupport.
6366
/// It follows the Concept-Model pattern used throughout MLIR (e.g., in
@@ -69,6 +72,13 @@ struct OpenACCSupportTraits {
6972

7073
/// Get the variable name for a given MLIR value.
7174
virtual std::string getVariableName(Value v) = 0;
75+
76+
/// Get the recipe name for a given kind, type and value.
77+
virtual std::string getRecipeName(RecipeKind kind, Type type,
78+
Value var) = 0;
79+
80+
// Used to report a case that is not supported by the implementation.
81+
virtual InFlightDiagnostic emitNYI(Location loc, const Twine &message) = 0;
7282
};
7383

7484
/// This class wraps a concrete OpenACCSupport implementation and forwards
@@ -84,6 +94,14 @@ struct OpenACCSupportTraits {
8494
return impl.getVariableName(v);
8595
}
8696

97+
std::string getRecipeName(RecipeKind kind, Type type, Value var) final {
98+
return impl.getRecipeName(kind, type, var);
99+
}
100+
101+
InFlightDiagnostic emitNYI(Location loc, const Twine &message) final {
102+
return impl.emitNYI(loc, message);
103+
}
104+
87105
private:
88106
ImplT impl;
89107
};
@@ -118,6 +136,24 @@ class OpenACCSupport {
118136
/// \return The variable name, or an empty string if unavailable.
119137
std::string getVariableName(Value v);
120138

139+
/// Get the recipe name for a given type and value.
140+
///
141+
/// \param kind The kind of recipe to get the name for.
142+
/// \param type The type to get the recipe name for. Can be null if the
143+
/// var is provided instead.
144+
/// \param var The MLIR value to get the recipe name for. Can be null if
145+
/// the type is provided instead.
146+
/// \return The recipe name, or an empty string if not available.
147+
std::string getRecipeName(RecipeKind kind, Type type, Value var);
148+
149+
/// Report a case that is not yet supported by the implementation.
150+
///
151+
/// \param loc The location to report the unsupported case at.
152+
/// \param message The message to report.
153+
/// \return An in-flight diagnostic object that can be used to report the
154+
/// unsupported case.
155+
InFlightDiagnostic emitNYI(Location loc, const Twine &message);
156+
121157
/// Signal that this analysis should always be preserved so that
122158
/// underlying implementation registration is not lost.
123159
bool isInvalidated(const AnalysisManager::PreservedAnalyses &pa) {

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@ def OpenACC_LoopParMode : I32EnumAttr<
152152
let genSpecializedAttr = 0;
153153
}
154154

155+
def OpenACC_PrivateRecipe : I32EnumAttrCase<"private_recipe", 0>;
156+
def OpenACC_FirstprivateRecipe : I32EnumAttrCase<"firstprivate_recipe", 1>;
157+
def OpenACC_ReductionRecipe : I32EnumAttrCase<"reduction_recipe", 2>;
158+
159+
def OpenACC_RecipeKind : I32EnumAttr<
160+
"RecipeKind",
161+
"Encodes the options for kinds of recipes availabie in acc dialect",
162+
[
163+
OpenACC_PrivateRecipe, OpenACC_FirstprivateRecipe,
164+
OpenACC_ReductionRecipe]> {
165+
let cppNamespace = "::mlir::acc";
166+
let genSpecializedAttr = 0;
167+
}
168+
169+
def OpenACC_RecipeKindAttr : EnumAttr<OpenACC_Dialect,
170+
OpenACC_RecipeKind,
171+
"recipe_kind"> {
172+
let assemblyFormat = [{ ```<` $value `>` }];
173+
}
174+
155175
// Type used in operation below.
156176
def IntOrIndex : AnyTypeOf<[AnyInteger, Index]>;
157177

mlir/include/mlir/Dialect/OpenACC/OpenACCUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ mlir::acc::VariableTypeCategory getTypeCategory(mlir::Value var);
4343
/// empty string if no name is found.
4444
std::string getVariableName(mlir::Value v);
4545

46+
/// Get the recipe name for a given recipe kind and type.
47+
/// Returns an empty string if not possible to generate a recipe name.
48+
std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type);
49+
4650
} // namespace acc
4751
} // namespace mlir
4852

mlir/lib/Dialect/ControlFlow/Transforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_mlir_dialect_library(MLIRControlFlowTransforms
22
BufferDeallocationOpInterfaceImpl.cpp
33
BufferizableOpInterfaceImpl.cpp
4+
StructuralTypeConversions.cpp
45

56
ADDITIONAL_HEADER_DIRS
67
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/ControlFlow/Transforms

0 commit comments

Comments
 (0)