Skip to content

Commit 9692db5

Browse files
authored
merge main into amd-staging (llvm#4257)
2 parents cdfd34a + 5c04b63 commit 9692db5

File tree

24 files changed

+288
-151
lines changed

24 files changed

+288
-151
lines changed

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ void PGOHash::combine(HashType Type) {
972972
if (Count && Count % NumTypesPerWord == 0) {
973973
using namespace llvm::support;
974974
uint64_t Swapped =
975-
endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
975+
endian::byte_swap<uint64_t>(Working, llvm::endianness::little);
976976
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
977977
Working = 0;
978978
}
@@ -999,7 +999,7 @@ uint64_t PGOHash::finalize() {
999999
} else {
10001000
using namespace llvm::support;
10011001
uint64_t Swapped =
1002-
endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
1002+
endian::byte_swap<uint64_t>(Working, llvm::endianness::little);
10031003
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
10041004
}
10051005
}

lld/test/ELF/eh-frame-relocation.s

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# REQUIRES: x86
2+
## Test that marker relocations are ignored and undefined symbols lead to errors.
3+
4+
# RUN: rm -rf %t && split-file %s %t && cd %t
5+
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
6+
# RUN: llvm-mc -filetype=obj -triple=x86_64 abi.s -o abi.o
7+
# RUN: ld.lld a.o abi.o -o a
8+
# RUN: llvm-readelf -s a | FileCheck %s
9+
10+
# CHECK: 00000000002{{.*}} 0 FUNC GLOBAL DEFAULT [[#]] __gxx_personality_v0
11+
12+
# RUN: not ld.lld a.o 2>&1 | FileCheck %s --check-prefix=ERR
13+
14+
# ERR: error: undefined symbol: __gxx_personality_v0
15+
# ERR-NEXT: >>> referenced by a.o:(.eh_frame+0x12)
16+
17+
#--- a.s
18+
.cfi_startproc
19+
.cfi_personality 0, __gxx_personality_v0
20+
ret
21+
.cfi_endproc
22+
23+
.section .eh_frame,"a",@unwind
24+
.reloc ., BFD_RELOC_NONE, ignore
25+
26+
#--- abi.s
27+
.globl __gxx_personality_v0
28+
.type __gxx_personality_v0, @function
29+
__gxx_personality_v0:

llvm/docs/FuzzingLLVM.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ clang-proto-fuzzer
3333
A |protobuf fuzzer| that compiles valid C++ programs generated from a protobuf
3434
class that describes a subset of the C++ language.
3535

36-
This fuzzer accepts clang command line options after `ignore_remaining_args=1`.
36+
This fuzzer accepts clang command-line options after `ignore_remaining_args=1`.
3737
For example, the following command will fuzz clang with a higher optimization
3838
level:
3939

@@ -106,7 +106,7 @@ llvm-opt-fuzzer
106106

107107
A |LLVM IR fuzzer| aimed at finding bugs in optimization passes.
108108

109-
It receives optimization pipeline and runs it for each fuzzer input.
109+
It receives an optimization pipeline and runs it for each fuzzer input.
110110

111111
Interface of this fuzzer almost directly mirrors ``llvm-isel-fuzzer``. Both
112112
``mtriple`` and ``passes`` arguments are required. Passes are specified in a
@@ -117,7 +117,7 @@ this format in the doxygen for ``PassBuilder::parsePassPipeline``.
117117
118118
% bin/llvm-opt-fuzzer <corpus-dir> -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine
119119
120-
Similarly to the ``llvm-isel-fuzzer`` arguments in some predefined configurations
120+
Similarly to the ``llvm-isel-fuzzer``, arguments in some predefined configurations
121121
might be embedded directly into the binary file name:
122122

123123
.. code-block:: shell
@@ -176,7 +176,7 @@ mutations that a fuzzer in LLVM might want.
176176
Generic Random Fuzzing
177177
----------------------
178178

179-
The most basic form of input mutation is to use the built in mutators of
179+
The most basic form of input mutation is to use the built-in mutators of
180180
LibFuzzer. These simply treat the input corpus as a bag of bits and make random
181181
mutations. This type of fuzzer is good for stressing the surface layers of a
182182
program, and is good at testing things like lexers, parsers, or binary
@@ -244,7 +244,7 @@ by adding the following two flags to your CMake invocation:
244244
to avoid building the sanitizers themselves with sanitizers enabled.
245245

246246
.. note:: You may run into issues if you build with BFD ld, which is the
247-
default linker on many unix systems. These issues are being tracked
247+
default linker on many Unix systems. These issues are being tracked
248248
in https://llvm.org/PR34636.
249249

250250
Continuously Running and Finding Bugs
@@ -280,6 +280,6 @@ your fuzzer can be built and tested when not built against libFuzzer.
280280

281281
There is also some handling of the CMake config for fuzzers, where you should
282282
use the ``add_llvm_fuzzer`` to set up fuzzer targets. This function works
283-
similarly to functions such as ``add_llvm_tool``, but they take care of linking
283+
similarly to functions such as ``add_llvm_tool``, but it takes care of linking
284284
to LibFuzzer when appropriate and can be passed the ``DUMMY_MAIN`` argument to
285285
enable standalone testing.

llvm/include/llvm/ADT/ImmutableMap.h

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,25 @@ class ImmutableMap {
111111
}
112112
};
113113

114-
bool contains(key_type_ref K) const {
114+
[[nodiscard]] bool contains(key_type_ref K) const {
115115
return Root ? Root->contains(K) : false;
116116
}
117117

118-
bool operator==(const ImmutableMap &RHS) const {
118+
[[nodiscard]] bool operator==(const ImmutableMap &RHS) const {
119119
return Root && RHS.Root ? Root->isEqual(*RHS.Root.get()) : Root == RHS.Root;
120120
}
121121

122-
bool operator!=(const ImmutableMap &RHS) const {
122+
[[nodiscard]] bool operator!=(const ImmutableMap &RHS) const {
123123
return Root && RHS.Root ? Root->isNotEqual(*RHS.Root.get())
124124
: Root != RHS.Root;
125125
}
126126

127-
TreeTy *getRoot() const {
127+
[[nodiscard]] TreeTy *getRoot() const {
128128
if (Root) { Root->retain(); }
129129
return Root.get();
130130
}
131131

132-
TreeTy *getRootWithoutRetain() const { return Root.get(); }
132+
[[nodiscard]] TreeTy *getRootWithoutRetain() const { return Root.get(); }
133133

134134
void manualRetain() {
135135
if (Root) Root->retain();
@@ -139,7 +139,7 @@ class ImmutableMap {
139139
if (Root) Root->release();
140140
}
141141

142-
bool isEmpty() const { return !Root; }
142+
[[nodiscard]] bool isEmpty() const { return !Root; }
143143

144144
public:
145145
//===--------------------------------------------------===//
@@ -163,10 +163,10 @@ class ImmutableMap {
163163
data_type_ref getData() const { return (*this)->second; }
164164
};
165165

166-
iterator begin() const { return iterator(Root.get()); }
167-
iterator end() const { return iterator(); }
166+
[[nodiscard]] iterator begin() const { return iterator(Root.get()); }
167+
[[nodiscard]] iterator end() const { return iterator(); }
168168

169-
data_type* lookup(key_type_ref K) const {
169+
[[nodiscard]] data_type *lookup(key_type_ref K) const {
170170
if (Root) {
171171
TreeTy* T = Root->find(K);
172172
if (T) return &T->getValue().second;
@@ -178,15 +178,17 @@ class ImmutableMap {
178178
/// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
179179
/// which key is the highest in the ordering of keys in the map. This
180180
/// method returns NULL if the map is empty.
181-
value_type* getMaxElement() const {
181+
[[nodiscard]] value_type *getMaxElement() const {
182182
return Root ? &(Root->getMaxElement()->getValue()) : nullptr;
183183
}
184184

185185
//===--------------------------------------------------===//
186186
// Utility methods.
187187
//===--------------------------------------------------===//
188188

189-
unsigned getHeight() const { return Root ? Root->getHeight() : 0; }
189+
[[nodiscard]] unsigned getHeight() const {
190+
return Root ? Root->getHeight() : 0;
191+
}
190192

191193
static inline void Profile(FoldingSetNodeID& ID, const ImmutableMap& M) {
192194
ID.AddPointer(M.Root.get());
@@ -250,24 +252,24 @@ class ImmutableMapRef {
250252
return ImmutableMapRef(NewT, Factory);
251253
}
252254

253-
bool contains(key_type_ref K) const {
255+
[[nodiscard]] bool contains(key_type_ref K) const {
254256
return Root ? Root->contains(K) : false;
255257
}
256258

257259
ImmutableMap<KeyT, ValT> asImmutableMap() const {
258260
return ImmutableMap<KeyT, ValT>(Factory->getCanonicalTree(Root.get()));
259261
}
260262

261-
bool operator==(const ImmutableMapRef &RHS) const {
263+
[[nodiscard]] bool operator==(const ImmutableMapRef &RHS) const {
262264
return Root && RHS.Root ? Root->isEqual(*RHS.Root.get()) : Root == RHS.Root;
263265
}
264266

265-
bool operator!=(const ImmutableMapRef &RHS) const {
267+
[[nodiscard]] bool operator!=(const ImmutableMapRef &RHS) const {
266268
return Root && RHS.Root ? Root->isNotEqual(*RHS.Root.get())
267269
: Root != RHS.Root;
268270
}
269271

270-
bool isEmpty() const { return !Root; }
272+
[[nodiscard]] bool isEmpty() const { return !Root; }
271273

272274
//===--------------------------------------------------===//
273275
// For testing.
@@ -293,10 +295,10 @@ class ImmutableMapRef {
293295
data_type_ref getData() const { return (*this)->second; }
294296
};
295297

296-
iterator begin() const { return iterator(Root.get()); }
297-
iterator end() const { return iterator(); }
298+
[[nodiscard]] iterator begin() const { return iterator(Root.get()); }
299+
[[nodiscard]] iterator end() const { return iterator(); }
298300

299-
data_type *lookup(key_type_ref K) const {
301+
[[nodiscard]] data_type *lookup(key_type_ref K) const {
300302
if (Root) {
301303
TreeTy* T = Root->find(K);
302304
if (T) return &T->getValue().second;
@@ -308,15 +310,17 @@ class ImmutableMapRef {
308310
/// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
309311
/// which key is the highest in the ordering of keys in the map. This
310312
/// method returns NULL if the map is empty.
311-
value_type* getMaxElement() const {
313+
[[nodiscard]] value_type *getMaxElement() const {
312314
return Root ? &(Root->getMaxElement()->getValue()) : nullptr;
313315
}
314316

315317
//===--------------------------------------------------===//
316318
// Utility methods.
317319
//===--------------------------------------------------===//
318320

319-
unsigned getHeight() const { return Root ? Root->getHeight() : 0; }
321+
[[nodiscard]] unsigned getHeight() const {
322+
return Root ? Root->getHeight() : 0;
323+
}
320324

321325
static inline void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M) {
322326
ID.AddPointer(M.Root.get());

llvm/include/llvm/ADT/PackedVector.h

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PackedVectorBase<T, BitNum, BitVectorTy, true> {
4747
protected:
4848
static T getValue(const BitVectorTy &Bits, unsigned Idx) {
4949
T val = T();
50-
for (unsigned i = 0; i != BitNum-1; ++i)
50+
for (unsigned i = 0; i != BitNum - 1; ++i)
5151
val = T(val | ((Bits[(Idx * BitNum) + i] ? 1UL : 0UL) << i));
5252
if (Bits[(Idx * BitNum) + BitNum - 1])
5353
val = ~val;
@@ -58,9 +58,11 @@ class PackedVectorBase<T, BitNum, BitVectorTy, true> {
5858
if (val < 0) {
5959
val = ~val;
6060
Bits.set((Idx * BitNum) + BitNum - 1);
61+
} else {
62+
Bits.reset((Idx * BitNum) + BitNum - 1);
6163
}
62-
assert((val >> (BitNum-1)) == 0 && "value is too big");
63-
for (unsigned i = 0; i != BitNum-1; ++i)
64+
assert((val >> (BitNum - 1)) == 0 && "value is too big");
65+
for (unsigned i = 0; i != BitNum - 1; ++i)
6466
Bits[(Idx * BitNum) + i] = val & (T(1) << i);
6567
}
6668
};
@@ -73,8 +75,9 @@ class PackedVectorBase<T, BitNum, BitVectorTy, true> {
7375
/// will create a vector accepting values -2, -1, 0, 1. Any other value will hit
7476
/// an assertion.
7577
template <typename T, unsigned BitNum, typename BitVectorTy = BitVector>
76-
class PackedVector : public PackedVectorBase<T, BitNum, BitVectorTy,
77-
std::numeric_limits<T>::is_signed> {
78+
class PackedVector
79+
: public PackedVectorBase<T, BitNum, BitVectorTy,
80+
std::numeric_limits<T>::is_signed> {
7881
BitVectorTy Bits;
7982
// Keep track of the number of elements on our own.
8083
// We always maintain Bits.size() == NumElements * BitNum.
@@ -97,9 +100,7 @@ class PackedVector : public PackedVectorBase<T, BitNum, BitVectorTy,
97100
return *this;
98101
}
99102

100-
operator T() const {
101-
return Vec.getValue(Vec.Bits, Idx);
102-
}
103+
operator T() const { return Vec.getValue(Vec.Bits, Idx); }
103104
};
104105

105106
PackedVector() = default;
@@ -128,25 +129,17 @@ class PackedVector : public PackedVectorBase<T, BitNum, BitVectorTy,
128129
}
129130

130131
void push_back(T val) {
131-
resize(size()+1);
132-
(*this)[size()-1] = val;
132+
resize(size() + 1);
133+
(*this)[size() - 1] = val;
133134
}
134135

135-
reference operator[](unsigned Idx) {
136-
return reference(*this, Idx);
137-
}
136+
reference operator[](unsigned Idx) { return reference(*this, Idx); }
138137

139-
T operator[](unsigned Idx) const {
140-
return base::getValue(Bits, Idx);
141-
}
138+
T operator[](unsigned Idx) const { return base::getValue(Bits, Idx); }
142139

143-
bool operator==(const PackedVector &RHS) const {
144-
return Bits == RHS.Bits;
145-
}
140+
bool operator==(const PackedVector &RHS) const { return Bits == RHS.Bits; }
146141

147-
bool operator!=(const PackedVector &RHS) const {
148-
return Bits != RHS.Bits;
149-
}
142+
bool operator!=(const PackedVector &RHS) const { return Bits != RHS.Bits; }
150143

151144
PackedVector &operator|=(const PackedVector &RHS) {
152145
Bits |= RHS.Bits;

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,18 @@ class SmallVectorTemplateCommon
199199
}
200200

201201
/// Check whether any part of the range will be invalidated by clearing.
202-
void assertSafeToReferenceAfterClear(const T *From, const T *To) {
203-
if (From == To)
204-
return;
205-
this->assertSafeToReferenceAfterResize(From, 0);
206-
this->assertSafeToReferenceAfterResize(To - 1, 0);
207-
}
208-
template <
209-
class ItTy,
210-
std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>, T *>::value,
211-
bool> = false>
212-
void assertSafeToReferenceAfterClear(ItTy, ItTy) {}
202+
template <class ItTy>
203+
void assertSafeToReferenceAfterClear(ItTy From, ItTy To) {
204+
if constexpr (std::is_pointer_v<ItTy> &&
205+
std::is_same_v<
206+
std::remove_const_t<std::remove_pointer_t<ItTy>>,
207+
std::remove_const_t<T>>) {
208+
if (From == To)
209+
return;
210+
this->assertSafeToReferenceAfterResize(From, 0);
211+
this->assertSafeToReferenceAfterResize(To - 1, 0);
212+
}
213+
}
213214

214215
/// Check whether any part of the range will be invalidated by growing.
215216
template <class ItTy> void assertSafeToAddRange(ItTy From, ItTy To) {

0 commit comments

Comments
 (0)