Skip to content

Commit 5695f56

Browse files
authored
Merge branch 'main' into qualwg-docs-restructure
2 parents 546a53c + 84a796d commit 5695f56

File tree

5 files changed

+27
-45
lines changed

5 files changed

+27
-45
lines changed

llvm/docs/FAQ.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test LLVM have been ported to a plethora of platforms.
5050
What API do I use to store a value to one of the virtual registers in LLVM IR's SSA representation?
5151
---------------------------------------------------------------------------------------------------
5252

53-
In short: you can't. It's actually kind of a silly question once you grok
53+
In short: you can't. It's actually kind of a silly question once you understand
5454
what's going on. Basically, in code like:
5555

5656
.. code-block:: llvm
@@ -80,7 +80,7 @@ What source languages are supported?
8080

8181
LLVM currently has full support for C and C++ source languages through
8282
`Clang <https://clang.llvm.org/>`_. Many other language frontends have
83-
been written using LLVM, and an incomplete list is available at
83+
been written using LLVM; an incomplete list is available at
8484
`projects with LLVM <https://llvm.org/ProjectsWithLLVM/>`_.
8585

8686

@@ -91,12 +91,12 @@ LLVM intermediate representation (IR) format. Assuming you want to write your
9191
language's compiler in the language itself (rather than C++), there are 3
9292
major ways to tackle generating LLVM IR from a front-end:
9393

94-
1. **Call into the LLVM libraries code using your language's FFI (foreign
94+
1. **Call into the LLVM libraries using your language's FFI (foreign
9595
function interface).**
9696

9797
* *for:* best tracks changes to the LLVM IR, .ll syntax, and .bc format
9898

99-
* *for:* enables running LLVM optimization passes without a emit/parse
99+
* *for:* enables running LLVM optimization passes without an emit/parse
100100
overhead
101101

102102
* *for:* adapts well to a JIT context
@@ -128,10 +128,10 @@ most common hurdle with calling C from managed code is interfacing with the
128128
garbage collector. The C interface was designed to require very little memory
129129
management, and so is straightforward in this regard.
130130

131-
What support is there for a higher level source language constructs for building a compiler?
131+
What support is there for a higher-level source language constructs for building a compiler?
132132
--------------------------------------------------------------------------------------------
133133
Currently, there isn't much. LLVM supports an intermediate representation
134-
which is useful for code representation but will not support the high level
134+
which is useful for code representation but will not support the high-level
135135
(abstract syntax tree) representation needed by most compilers. There are no
136136
facilities for lexical nor semantic analysis.
137137

@@ -215,7 +215,7 @@ for it.
215215

216216
Why does instcombine + simplifycfg turn a call to a function with a mismatched calling convention into "unreachable"? Why not make the verifier reject it?
217217
----------------------------------------------------------------------------------------------------------------------------------------------------------
218-
This is a common problem run into by authors of front-ends that are using
218+
This is a common problem encountered by authors of front-ends that are using
219219
custom calling conventions: you need to make sure to set the right calling
220220
convention on both the function and on each call to the function. For
221221
example, this code:
@@ -274,7 +274,7 @@ Here's an example:
274274
}
275275
276276
In this example, "test" always passes ``@foo``/``false`` into ``bar``, which
277-
ensures that it is dynamically called with the right calling conv (thus, the
277+
ensures that it is dynamically called with the right calling convention (thus, the
278278
code is perfectly well defined). If you run this through the inliner, you
279279
get this (the explicit "or" is there so that the inliner doesn't dead code
280280
eliminate a bunch of stuff):

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,22 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
231231

232232
// The pointers to call/move/destroy functions are determined for each
233233
// callable type (and called-as type, which determines the overload chosen).
234-
// (definitions are out-of-line).
235234

236235
// By default, we need an object that contains all the different
237236
// type erased behaviors needed. Create a static instance of the struct type
238237
// here and each instance will contain a pointer to it.
239238
// Wrap in a struct to avoid https://gcc.gnu.org/PR71954
240239
template <typename CallableT, typename CalledAs, typename Enable = void>
241240
struct CallbacksHolder {
242-
static NonTrivialCallbacks Callbacks;
241+
inline static NonTrivialCallbacks Callbacks = {
242+
&CallImpl<CalledAs>, &MoveImpl<CallableT>, &DestroyImpl<CallableT>};
243243
};
244244
// See if we can create a trivial callback. We need the callable to be
245245
// trivially moved and trivially destroyed so that we don't have to store
246246
// type erased callbacks for those operations.
247247
template <typename CallableT, typename CalledAs>
248248
struct CallbacksHolder<CallableT, CalledAs, EnableIfTrivial<CallableT>> {
249-
static TrivialCallback Callbacks;
249+
inline static TrivialCallback Callbacks = {&CallImpl<CalledAs>};
250250
};
251251

252252
// A simple tag type so the call-as type to be passed to the constructor.
@@ -344,19 +344,6 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
344344
}
345345
};
346346

347-
template <typename R, typename... P>
348-
template <typename CallableT, typename CalledAsT, typename Enable>
349-
typename UniqueFunctionBase<R, P...>::NonTrivialCallbacks UniqueFunctionBase<
350-
R, P...>::CallbacksHolder<CallableT, CalledAsT, Enable>::Callbacks = {
351-
&CallImpl<CalledAsT>, &MoveImpl<CallableT>, &DestroyImpl<CallableT>};
352-
353-
template <typename R, typename... P>
354-
template <typename CallableT, typename CalledAsT>
355-
typename UniqueFunctionBase<R, P...>::TrivialCallback
356-
UniqueFunctionBase<R, P...>::CallbacksHolder<
357-
CallableT, CalledAsT, EnableIfTrivial<CallableT>>::Callbacks{
358-
&CallImpl<CalledAsT>};
359-
360347
} // namespace detail
361348

362349
template <typename R, typename... P>

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,16 @@ class SmallVectorTemplateCommon
212212
void assertSafeToReferenceAfterClear(ItTy, ItTy) {}
213213

214214
/// Check whether any part of the range will be invalidated by growing.
215-
void assertSafeToAddRange(const T *From, const T *To) {
216-
if (From == To)
217-
return;
218-
this->assertSafeToAdd(From, To - From);
219-
this->assertSafeToAdd(To - 1, To - From);
215+
template <class ItTy> void assertSafeToAddRange(ItTy From, ItTy To) {
216+
if constexpr (std::is_pointer_v<ItTy> &&
217+
std::is_same_v<std::remove_cv_t<std::remove_pointer_t<ItTy>>,
218+
T>) {
219+
if (From == To)
220+
return;
221+
this->assertSafeToAdd(From, To - From);
222+
this->assertSafeToAdd(To - 1, To - From);
223+
}
220224
}
221-
template <
222-
class ItTy,
223-
std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>, T *>::value,
224-
bool> = false>
225-
void assertSafeToAddRange(ItTy, ItTy) {}
226225

227226
/// Reserve enough space to add one element, and return the updated element
228227
/// pointer in case it was a reference to the storage.

llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,8 @@ Error MachOLinkGraphBuilder::createNormalizedSections() {
203203
llvm::sort(Sections,
204204
[](const NormalizedSection *LHS, const NormalizedSection *RHS) {
205205
assert(LHS && RHS && "Null section?");
206-
if (LHS->Address != RHS->Address)
207-
return LHS->Address < RHS->Address;
208-
return LHS->Size < RHS->Size;
206+
return std::tie(LHS->Address, LHS->Size) <
207+
std::tie(RHS->Address, RHS->Size);
209208
});
210209

211210
for (unsigned I = 0, E = Sections.size() - 1; I != E; ++I) {

llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,15 @@ using namespace llvm::AMDGPU;
5656
std::true_type>; \
5757
}; \
5858
class IsMCExpr##member { \
59-
template <typename U, \
60-
typename std::enable_if_t< \
61-
HasMember##member::RESULT && \
62-
std::is_same_v<decltype(U::member), const MCExpr *>, \
63-
U> * = nullptr> \
64-
static constexpr std::true_type HasMCExprType(decltype(U::member) *); \
59+
template <typename U> \
60+
static constexpr auto HasMCExprType(int) -> std::bool_constant< \
61+
HasMember##member::RESULT && \
62+
std::is_same_v<decltype(U::member), const MCExpr *>>; \
6563
template <typename U> static constexpr std::false_type HasMCExprType(...); \
6664
\
6765
public: \
6866
static constexpr bool RESULT = \
69-
std::is_same_v<decltype(HasMCExprType<AMDGPUMCKernelCodeT>(nullptr)), \
70-
std::true_type>; \
67+
decltype(HasMCExprType<AMDGPUMCKernelCodeT>(0))::value; \
7168
}; \
7269
class GetMember##member { \
7370
public: \

0 commit comments

Comments
 (0)