Skip to content

Commit 0e3e9b5

Browse files
authored
Update compiler-rt to LLVM 17.0.4 (#20708)
On top of the main library code changes, each fix that was necessary for Emscripten was committed separately with its own commit message within the PR.
1 parent ee88173 commit 0e3e9b5

File tree

176 files changed

+3072
-1408
lines changed

Some content is hidden

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

176 files changed

+3072
-1408
lines changed

system/lib/compiler-rt/include/sanitizer/allocator_interface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ extern "C" {
2626
is not yet freed. */
2727
int __sanitizer_get_ownership(const volatile void *p);
2828

29+
/* If a pointer lies within an allocation, it will return the start address
30+
of the allocation. Otherwise, it returns nullptr. */
31+
const void *__sanitizer_get_allocated_begin(const void *p);
32+
2933
/* Returns the number of bytes reserved for the pointer p.
3034
Requires (get_ownership(p) == true) or (p == 0). */
3135
size_t __sanitizer_get_allocated_size(const volatile void *p);
3236

37+
/* Returns the number of bytes reserved for the pointer p.
38+
Requires __sanitizer_get_allocated_begin(p) == p. */
39+
size_t __sanitizer_get_allocated_size_fast(const volatile void *p);
40+
3341
/* Number of bytes, allocated and not yet freed by the application. */
3442
size_t __sanitizer_get_current_allocated_bytes(void);
3543

system/lib/compiler-rt/include/sanitizer/common_interface_defs.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,23 @@ int __sanitizer_acquire_crash_state();
129129
/// state <c>mid == end</c>, so that should be the final state when the
130130
/// container is destroyed or when the container reallocates the storage.
131131
///
132-
/// For ASan, <c><i>beg</i></c> should be 8-aligned and <c><i>end</i></c>
133-
/// should be either 8-aligned or it should point to the end of a separate
134-
/// heap-, stack-, or global-allocated buffer. So the following example will
135-
/// not work:
132+
/// For ASan, <c><i>beg</i></c> no longer needs to be 8-aligned,
133+
/// first and last granule may be shared with other objects
134+
/// and therefore the function can be used for any allocator.
136135
///
137-
/// \code
138-
/// int64_t x[2]; // 16 bytes, 8-aligned
139-
/// char *beg = (char *)&x[0];
140-
/// char *end = beg + 12; // Not 8-aligned, not the end of the buffer
141-
/// \endcode
136+
/// The following example shows how to use the function:
142137
///
143-
/// The following, however, will work:
144138
/// \code
145-
/// int32_t x[3]; // 12 bytes, but 8-aligned under ASan.
139+
/// int32_t x[3]; // 12 bytes
146140
/// char *beg = (char*)&x[0];
147-
/// char *end = beg + 12; // Not 8-aligned, but is the end of the buffer
141+
/// char *end = beg + 12;
142+
/// __sanitizer_annotate_contiguous_container(beg, end, beg, end);
148143
/// \endcode
149144
///
150145
/// \note Use this function with caution and do not use for anything other
151146
/// than vector-like classes.
147+
/// \note Unaligned <c><i>beg</i></c> or <c><i>end</i></c> may miss bugs in
148+
/// these granules.
152149
///
153150
/// \param beg Beginning of memory region.
154151
/// \param end End of memory region.

system/lib/compiler-rt/include/sanitizer/hwasan_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- sanitizer/asan_interface.h ------------------------------*- C++ -*-===//
1+
//===-- sanitizer/hwasan_interface.h ----------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

system/lib/compiler-rt/include/sanitizer/tsan_interface.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,129 @@ int __tsan_on_finalize(int failed);
172172
// Release TSan internal memory in a best-effort manner.
173173
void __tsan_flush_memory();
174174

175+
// User-provided default TSAN options.
176+
const char* __tsan_default_options(void);
177+
178+
// User-provided default TSAN suppressions.
179+
const char* __tsan_default_suppressions(void);
180+
181+
/// Returns a report's description.
182+
///
183+
/// Returns a report's description (issue type), number of duplicate issues
184+
/// found, counts of array data (stack traces, memory operations, locations,
185+
/// mutexes, threads, unique thread IDs) and a stack trace of a <c>sleep()</c>
186+
/// call (if one was involved in the issue).
187+
///
188+
/// \param report Opaque pointer to the current report.
189+
/// \param[out] description Report type description.
190+
/// \param[out] count Count of duplicate issues.
191+
/// \param[out] stack_count Count of stack traces.
192+
/// \param[out] mop_count Count of memory operations.
193+
/// \param[out] loc_count Count of locations.
194+
/// \param[out] mutex_count Count of mutexes.
195+
/// \param[out] thread_count Count of threads.
196+
/// \param[out] unique_tid_count Count of unique thread IDs.
197+
/// \param sleep_trace A buffer to store the stack trace of a <c>sleep()</c>
198+
/// call.
199+
/// \param trace_size Size in bytes of the trace buffer.
200+
/// \returns Returns 1 if successful, 0 if not.
201+
int __tsan_get_report_data(void *report, const char **description, int *count,
202+
int *stack_count, int *mop_count, int *loc_count,
203+
int *mutex_count, int *thread_count,
204+
int *unique_tid_count, void **sleep_trace,
205+
unsigned long trace_size);
206+
207+
/// Returns information about stack traces included in the report.
208+
///
209+
/// \param report Opaque pointer to the current report.
210+
/// \param idx Index to the report's stacks.
211+
/// \param trace A buffer to store the stack trace.
212+
/// \param trace_size Size in bytes of the trace buffer.
213+
/// \returns Returns 1 if successful, 0 if not.
214+
int __tsan_get_report_stack(void *report, unsigned long idx, void **trace,
215+
unsigned long trace_size);
216+
217+
/// Returns information about memory operations included in the report.
218+
///
219+
/// \param report Opaque pointer to the current report.
220+
/// \param idx Index to the report's memory operations.
221+
/// \param[out] tid Thread ID of the memory operation.
222+
/// \param[out] addr Address of the memory operation.
223+
/// \param[out] size Size of the memory operation.
224+
/// \param[out] write Write flag of the memory operation.
225+
/// \param[out] atomic Atomicity flag of the memory operation.
226+
/// \param trace A buffer to store the stack trace.
227+
/// \param trace_size Size in bytes of the trace buffer.
228+
/// \returns Returns 1 if successful, 0 if not.
229+
int __tsan_get_report_mop(void *report, unsigned long idx, int *tid,
230+
void **addr, int *size, int *write, int *atomic,
231+
void **trace, unsigned long trace_size);
232+
233+
/// Returns information about locations included in the report.
234+
///
235+
/// \param report Opaque pointer to the current report.
236+
/// \param idx Index to the report's locations.
237+
/// \param[out] type Type of the location.
238+
/// \param[out] addr Address of the location.
239+
/// \param[out] start Start of the location.
240+
/// \param[out] size Size of the location.
241+
/// \param[out] tid Thread ID of the location.
242+
/// \param[out] fd File descriptor of the location.
243+
/// \param[out] suppressable Suppressable flag.
244+
/// \param trace A buffer to store the stack trace.
245+
/// \param trace_size Size in bytes of the trace buffer.
246+
/// \returns Returns 1 if successful, 0 if not.
247+
int __tsan_get_report_loc(void *report, unsigned long idx, const char **type,
248+
void **addr, void **start, unsigned long *size,
249+
int *tid, int *fd, int *suppressable, void **trace,
250+
unsigned long trace_size);
251+
252+
/// Returns information about mutexes included in the report.
253+
///
254+
/// \param report Opaque pointer to the current report.
255+
/// \param idx Index to the report's mutexes.
256+
/// \param[out] mutex_id Id of the mutex.
257+
/// \param[out] addr Address of the mutex.
258+
/// \param[out] destroyed Destroyed mutex flag.
259+
/// \param trace A buffer to store the stack trace.
260+
/// \param trace_size Size in bytes of the trace buffer.
261+
/// \returns Returns 1 if successful, 0 if not.
262+
int __tsan_get_report_mutex(void *report, unsigned long idx, uint64_t *mutex_id,
263+
void **addr, int *destroyed, void **trace,
264+
unsigned long trace_size);
265+
266+
/// Returns information about threads included in the report.
267+
///
268+
/// \param report Opaque pointer to the current report.
269+
/// \param idx Index to the report's threads.
270+
/// \param[out] tid Thread ID of the thread.
271+
/// \param[out] os_id Operating system's ID of the thread.
272+
/// \param[out] running Running flag of the thread.
273+
/// \param[out] name Name of the thread.
274+
/// \param[out] parent_tid ID of the parent thread.
275+
/// \param trace A buffer to store the stack trace.
276+
/// \param trace_size Size in bytes of the trace buffer.
277+
/// \returns Returns 1 if successful, 0 if not.
278+
int __tsan_get_report_thread(void *report, unsigned long idx, int *tid,
279+
uint64_t *os_id, int *running, const char **name,
280+
int *parent_tid, void **trace,
281+
unsigned long trace_size);
282+
283+
/// Returns information about unique thread IDs included in the report.
284+
///
285+
/// \param report Opaque pointer to the current report.
286+
/// \param idx Index to the report's unique thread IDs.
287+
/// \param[out] tid Unique thread ID of the report.
288+
/// \returns Returns 1 if successful, 0 if not.
289+
int __tsan_get_report_unique_tid(void *report, unsigned long idx, int *tid);
290+
291+
/// Returns the current report.
292+
///
293+
/// If TSan is currently reporting a detected issue on the current thread,
294+
/// returns an opaque pointer to the current report. Otherwise returns NULL.
295+
/// \returns An opaque pointer to the current report. Otherwise returns NULL.
296+
void *__tsan_get_current_report();
297+
175298
#ifdef __cplusplus
176299
} // extern "C"
177300
#endif

0 commit comments

Comments
 (0)