Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / print_address.h
blobdf31322246a083b03a887c4af426e2227cee2c39
1 #include <stdio.h>
2 #include <stdarg.h>
4 #ifndef __SANITIZER_COMMON_PRINT_ADDRESS_H__
5 # define __SANITIZER_COMMON_PRINT_ADDRESS_H__
7 void print_address(const char *str, int n, ...) {
8 fprintf(stderr, "%s", str);
9 va_list ap;
10 va_start(ap, n);
11 while (n--) {
12 void *p = va_arg(ap, void *);
13 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
14 defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) || \
15 defined(__loongarch_lp64)
16 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
17 // match to the format used in the diagnotic message.
18 fprintf(stderr, "0x%012lx ", (unsigned long) p);
19 #elif defined(__i386__) || defined(__arm__)
20 fprintf(stderr, "0x%08lx ", (unsigned long) p);
21 #elif defined(__mips64)
22 fprintf(stderr, "0x%010lx ", (unsigned long) p);
23 #endif
25 fprintf(stderr, "\n");
28 #endif // __SANITIZER_COMMON_PRINT_ADDRESS_H__