Skip to content

Commit 992afe2

Browse files
committed
Merge from 'main' to 'sycl-web' (5 commits)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
2 parents f48fb98 + 5404fe3 commit 992afe2

File tree

15 files changed

+327
-68
lines changed

15 files changed

+327
-68
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ code bases.
158158
}
159159
}
160160

161+
- The ``-fexperimental-new-pass-manager`` and ``-fno-legacy-pass-manager``
162+
flags have been removed. These have been no-ops since 15.0.0.
161163

162164
What's New in Clang |release|?
163165
==============================
@@ -258,6 +260,10 @@ Bug Fixes
258260
- Fix template arguments of pointer and reference not taking the type as
259261
part of their identity.
260262
`Issue 47136 <https://github.com/llvm/llvm-project/issues/47136>`_
263+
- Fix a crash when trying to form a recovery expression on a call inside a
264+
constraint, which re-evaluated the same constraint.
265+
`Issue 53213 <https://github.com/llvm/llvm-project/issues/53213>`_
266+
`Issue 45736 <https://github.com/llvm/llvm-project/issues/45736>`_
261267

262268
Improvements to Clang's diagnostics
263269
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,10 +2051,6 @@ def fglobal_isel : Flag<["-"], "fglobal-isel">, Group<f_clang_Group>,
20512051
HelpText<"Enables the global instruction selector">;
20522052
def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group<f_clang_Group>,
20532053
Alias<fglobal_isel>;
2054-
def fno_legacy_pass_manager : Flag<["-"], "fno-legacy-pass-manager">,
2055-
Group<f_clang_Group>, Flags<[CC1Option, NoArgumentUnused]>;
2056-
def fexperimental_new_pass_manager : Flag<["-"], "fexperimental-new-pass-manager">,
2057-
Group<f_clang_Group>, Flags<[CC1Option]>, Alias<fno_legacy_pass_manager>;
20582054
def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">,
20592055
Group<f_clang_Group>, Flags<[CC1Option]>,
20602056
HelpText<"Enables experimental strict floating point in LLVM.">,

clang/lib/Sema/SemaConcept.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,29 @@ bool Sema::CheckConstraintSatisfaction(
408408
OutSatisfaction = *Cached;
409409
return false;
410410
}
411+
411412
auto Satisfaction =
412413
std::make_unique<ConstraintSatisfaction>(Template, FlattenedArgs);
413414
if (::CheckConstraintSatisfaction(*this, Template, ConstraintExprs,
414415
ConvertedConstraints, TemplateArgsLists,
415416
TemplateIDRange, *Satisfaction)) {
416417
return true;
417418
}
419+
420+
if (auto *Cached = SatisfactionCache.FindNodeOrInsertPos(ID, InsertPos)) {
421+
// The evaluation of this constraint resulted in us trying to re-evaluate it
422+
// recursively. This isn't really possible, except we try to form a
423+
// RecoveryExpr as a part of the evaluation. If this is the case, just
424+
// return the 'cached' version (which will have the same result), and save
425+
// ourselves the extra-insert. If it ever becomes possible to legitimately
426+
// recursively check a constraint, we should skip checking the 'inner' one
427+
// above, and replace the cached version with this one, as it would be more
428+
// specific.
429+
OutSatisfaction = *Cached;
430+
return false;
431+
}
432+
433+
// Else we can simply add this satisfaction to the list.
418434
OutSatisfaction = *Satisfaction;
419435
// We cannot use InsertPos here because CheckConstraintSatisfaction might have
420436
// invalidated it.

clang/test/Driver/flegacy-pass-manager.c

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %clang_cc1 -std=c++20 -verify %s
2+
namespace GH53213 {
3+
template<typename T>
4+
concept c = requires(T t) { f(t); }; // #CDEF
5+
6+
auto f(c auto); // #FDEF
7+
8+
void g() {
9+
f(0);
10+
// expected-error@-1{{no matching function for call to 'f'}}
11+
// expected-note@#FDEF{{constraints not satisfied}}
12+
// expected-note@#FDEF{{because 'int' does not satisfy 'c'}}
13+
// expected-note@#CDEF{{because 'f(t)' would be invalid: no matching function for call to 'f'}}
14+
}
15+
} // namespace GH53213
16+
17+
namespace GH45736 {
18+
struct constrained;
19+
20+
template<typename T>
21+
struct type {
22+
};
23+
template<typename T>
24+
constexpr bool f(type<T>) {
25+
return true;
26+
}
27+
28+
template<typename T>
29+
concept matches = f(type<T>());
30+
31+
32+
struct constrained {
33+
template<typename U> requires matches<U>
34+
explicit constrained(U value) {
35+
}
36+
};
37+
38+
bool f(constrained const &) {
39+
return true;
40+
}
41+
42+
struct outer {
43+
constrained state;
44+
};
45+
46+
bool f(outer const & x) {
47+
return f(x.state);
48+
}
49+
} // namespace GH45736

llvm/docs/WritingAnLLVMPass.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ without modifying it then the third argument is set to ``true``; if a pass is
185185
an analysis pass, for example dominator tree pass, then ``true`` is supplied as
186186
the fourth argument.
187187

188+
If we want to register the pass as a step of an existing pipeline, some extension
189+
points are provided, e.g. ``PassManagerBuilder::EP_EarlyAsPossible`` to apply our
190+
pass before any optimization, or ``PassManagerBuilder::EP_FullLinkTimeOptimizationLast``
191+
to apply it after Link Time Optimizations.
192+
193+
.. code-block:: c++
194+
195+
static llvm::RegisterStandardPasses Y(
196+
llvm::PassManagerBuilder::EP_EarlyAsPossible,
197+
[](const llvm::PassManagerBuilder &Builder,
198+
llvm::legacy::PassManagerBase &PM) { PM.add(new Hello()); });
199+
188200
As a whole, the ``.cpp`` file looks like:
189201

190202
.. code-block:: c++
@@ -216,6 +228,11 @@ As a whole, the ``.cpp`` file looks like:
216228
false /* Only looks at CFG */,
217229
false /* Analysis Pass */);
218230
231+
static RegisterStandardPasses Y(
232+
PassManagerBuilder::EP_EarlyAsPossible,
233+
[](const PassManagerBuilder &Builder,
234+
legacy::PassManagerBase &PM) { PM.add(new Hello()); });
235+
219236
Now that it's all together, compile the file with a simple "``gmake``" command
220237
from the top level of your build directory and you should get a new file
221238
"``lib/LLVMHello.so``". Note that everything in this file is

llvm/examples/Bye/Bye.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ static RegisterPass<LegacyBye> X("goodbye", "Good Bye World Pass",
4444
false /* Only looks at CFG */,
4545
false /* Analysis Pass */);
4646

47+
/* Legacy PM Registration */
48+
static llvm::RegisterStandardPasses RegisterBye(
49+
llvm::PassManagerBuilder::EP_VectorizerStart,
50+
[](const llvm::PassManagerBuilder &Builder,
51+
llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); });
52+
53+
static llvm::RegisterStandardPasses RegisterByeLTO(
54+
llvm::PassManagerBuilder::EP_ModuleOptimizerEarly,
55+
[](const llvm::PassManagerBuilder &Builder,
56+
llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); });
57+
4758
/* New PM Registration */
4859
llvm::PassPluginLibraryInfo getByePluginInfo() {
4960
return {LLVM_PLUGIN_API_VERSION, "Bye", LLVM_VERSION_STRING,

llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,68 @@ class PassManagerBuilder {
6363
ExtensionFn;
6464
typedef int GlobalExtensionID;
6565

66+
enum ExtensionPointTy {
67+
/// EP_EarlyAsPossible - This extension point allows adding passes before
68+
/// any other transformations, allowing them to see the code as it is coming
69+
/// out of the frontend.
70+
EP_EarlyAsPossible,
71+
72+
/// EP_ModuleOptimizerEarly - This extension point allows adding passes
73+
/// just before the main module-level optimization passes.
74+
EP_ModuleOptimizerEarly,
75+
76+
/// EP_LoopOptimizerEnd - This extension point allows adding loop passes to
77+
/// the end of the loop optimizer.
78+
EP_LoopOptimizerEnd,
79+
80+
/// EP_ScalarOptimizerLate - This extension point allows adding optimization
81+
/// passes after most of the main optimizations, but before the last
82+
/// cleanup-ish optimizations.
83+
EP_ScalarOptimizerLate,
84+
85+
/// EP_OptimizerLast -- This extension point allows adding passes that
86+
/// run after everything else.
87+
EP_OptimizerLast,
88+
89+
/// EP_VectorizerStart - This extension point allows adding optimization
90+
/// passes before the vectorizer and other highly target specific
91+
/// optimization passes are executed.
92+
EP_VectorizerStart,
93+
94+
/// EP_EnabledOnOptLevel0 - This extension point allows adding passes that
95+
/// should not be disabled by O0 optimization level. The passes will be
96+
/// inserted after the inlining pass.
97+
EP_EnabledOnOptLevel0,
98+
99+
/// EP_Peephole - This extension point allows adding passes that perform
100+
/// peephole optimizations similar to the instruction combiner. These passes
101+
/// will be inserted after each instance of the instruction combiner pass.
102+
EP_Peephole,
103+
104+
/// EP_LateLoopOptimizations - This extension point allows adding late loop
105+
/// canonicalization and simplification passes. This is the last point in
106+
/// the loop optimization pipeline before loop deletion. Each pass added
107+
/// here must be an instance of LoopPass.
108+
/// This is the place to add passes that can remove loops, such as target-
109+
/// specific loop idiom recognition.
110+
EP_LateLoopOptimizations,
111+
112+
/// EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC
113+
/// passes at the end of the main CallGraphSCC passes and before any
114+
/// function simplification passes run by CGPassManager.
115+
EP_CGSCCOptimizerLate,
116+
117+
/// EP_FullLinkTimeOptimizationEarly - This extensions point allow adding
118+
/// passes that
119+
/// run at Link Time, before Full Link Time Optimization.
120+
EP_FullLinkTimeOptimizationEarly,
121+
122+
/// EP_FullLinkTimeOptimizationLast - This extensions point allow adding
123+
/// passes that
124+
/// run at Link Time, after Full Link Time Optimization.
125+
EP_FullLinkTimeOptimizationLast,
126+
};
127+
66128
/// The Optimization Level - Specify the basic optimization level.
67129
/// 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3
68130
unsigned OptLevel;
@@ -106,11 +168,32 @@ class PassManagerBuilder {
106168
unsigned LicmMssaOptCap;
107169
unsigned LicmMssaNoAccForPromotionCap;
108170

171+
private:
172+
/// ExtensionList - This is list of all of the extensions that are registered.
173+
std::vector<std::pair<ExtensionPointTy, ExtensionFn>> Extensions;
174+
109175
public:
110176
PassManagerBuilder();
111177
~PassManagerBuilder();
178+
/// Adds an extension that will be used by all PassManagerBuilder instances.
179+
/// This is intended to be used by plugins, to register a set of
180+
/// optimisations to run automatically.
181+
///
182+
/// \returns A global extension identifier that can be used to remove the
183+
/// extension.
184+
static GlobalExtensionID addGlobalExtension(ExtensionPointTy Ty,
185+
ExtensionFn Fn);
186+
/// Removes an extension that was previously added using addGlobalExtension.
187+
/// This is also intended to be used by plugins, to remove any extension that
188+
/// was previously registered before being unloaded.
189+
///
190+
/// \param ExtensionID Identifier of the extension to be removed.
191+
static void removeGlobalExtension(GlobalExtensionID ExtensionID);
192+
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn);
112193

113194
private:
195+
void addExtensionsToPM(ExtensionPointTy ETy,
196+
legacy::PassManagerBase &PM) const;
114197
void addInitialAliasAnalysisPasses(legacy::PassManagerBase &PM) const;
115198
void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM);
116199
void addVectorPasses(legacy::PassManagerBase &PM, bool IsFullLTO);
@@ -125,6 +208,27 @@ class PassManagerBuilder {
125208
void populateModulePassManager(legacy::PassManagerBase &MPM);
126209
};
127210

211+
/// Registers a function for adding a standard set of passes. This should be
212+
/// used by optimizer plugins to allow all front ends to transparently use
213+
/// them. Create a static instance of this class in your plugin, providing a
214+
/// private function that the PassManagerBuilder can use to add your passes.
215+
class RegisterStandardPasses {
216+
PassManagerBuilder::GlobalExtensionID ExtensionID;
217+
218+
public:
219+
RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty,
220+
PassManagerBuilder::ExtensionFn Fn) {
221+
ExtensionID = PassManagerBuilder::addGlobalExtension(Ty, std::move(Fn));
222+
}
223+
224+
~RegisterStandardPasses() {
225+
// If the collection holding the global extensions is destroyed after the
226+
// plugin is unloaded, the extension has to be removed here. Indeed, the
227+
// destructor of the ExtensionFn may reference code in the plugin.
228+
PassManagerBuilder::removeGlobalExtension(ExtensionID);
229+
}
230+
};
231+
128232
inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
129233
return reinterpret_cast<PassManagerBuilder*>(P);
130234
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5008,6 +5008,25 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
50085008
getDefaultScalableVLOps(I32ContainerVT, DL, DAG, Subtarget).first;
50095009
// Limit the active VL to two.
50105010
SDValue InsertI64VL = DAG.getConstant(2, DL, XLenVT);
5011+
// If the Idx is 0 we can insert directly into the vector.
5012+
if (isNullConstant(Idx)) {
5013+
// First slide in the lo value, then the hi in above it. We use slide1down
5014+
// to avoid the register group overlap constraint of vslide1up.
5015+
ValInVec = DAG.getNode(RISCVISD::VSLIDE1DOWN_VL, DL, I32ContainerVT,
5016+
Vec, Vec, ValLo, I32Mask, InsertI64VL);
5017+
// If the source vector is undef don't pass along the tail elements from
5018+
// the previous slide1down.
5019+
SDValue Tail = Vec.isUndef() ? Vec : ValInVec;
5020+
ValInVec = DAG.getNode(RISCVISD::VSLIDE1DOWN_VL, DL, I32ContainerVT,
5021+
Tail, ValInVec, ValHi, I32Mask, InsertI64VL);
5022+
// Bitcast back to the right container type.
5023+
ValInVec = DAG.getBitcast(ContainerVT, ValInVec);
5024+
5025+
if (!VecVT.isFixedLengthVector())
5026+
return ValInVec;
5027+
return convertFromScalableVector(VecVT, ValInVec, DAG, Subtarget);
5028+
}
5029+
50115030
// First slide in the lo value, then the hi in above it. We use slide1down
50125031
// to avoid the register group overlap constraint of vslide1up.
50135032
ValInVec = DAG.getNode(RISCVISD::VSLIDE1DOWN_VL, DL, I32ContainerVT,

0 commit comments

Comments
 (0)