Skip to content

Commit af6d53f

Browse files
authored
Merge branch 'main' into implicit
2 parents d332d76 + dfa5bbe commit af6d53f

File tree

49 files changed

+1199
-293
lines changed

Some content is hidden

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

49 files changed

+1199
-293
lines changed

clang/cmake/modules/ClangConfig.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
1010
set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
1111
set(CLANG_INCLUDE_DIRS "@CLANG_CONFIG_INCLUDE_DIRS@")
1212
set(CLANG_LINK_CLANG_DYLIB "@CLANG_LINK_CLANG_DYLIB@")
13+
set(CLANG_DEFAULT_LINKER "@CLANG_DEFAULT_LINKER@")
1314

1415
# Provide all our library targets to users.
1516
@CLANG_CONFIG_INCLUDE_EXPORTS@

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
# endif
2323
# include <stdio.h>
2424

25+
// Start searching for available memory region past PAGEZERO, which is
26+
// 4KB on 32-bit and 4GB on 64-bit.
27+
# define GAP_SEARCH_START_ADDRESS \
28+
((SANITIZER_WORDSIZE == 32) ? 0x000000001000 : 0x000100000000)
29+
2530
# include "sanitizer_common.h"
2631
# include "sanitizer_file.h"
2732
# include "sanitizer_flags.h"
@@ -58,6 +63,7 @@ extern char ***_NSGetArgv(void);
5863
# include <dlfcn.h> // for dladdr()
5964
# include <errno.h>
6065
# include <fcntl.h>
66+
# include <inttypes.h>
6167
# include <libkern/OSAtomic.h>
6268
# include <mach-o/dyld.h>
6369
# include <mach/mach.h>
@@ -1106,6 +1112,67 @@ static void StripEnv() {
11061112
}
11071113
#endif // SANITIZER_GO
11081114

1115+
// Prints out a consolidated memory map: contiguous regions
1116+
// are merged together.
1117+
static void PrintVmmap() {
1118+
const mach_vm_address_t max_vm_address = GetMaxVirtualAddress() + 1;
1119+
mach_vm_address_t address = GAP_SEARCH_START_ADDRESS;
1120+
kern_return_t kr = KERN_SUCCESS;
1121+
1122+
Report("Memory map:\n");
1123+
mach_vm_address_t last = 0;
1124+
mach_vm_address_t lastsz = 0;
1125+
1126+
while (1) {
1127+
mach_vm_size_t vmsize = 0;
1128+
natural_t depth = 0;
1129+
vm_region_submap_short_info_data_64_t vminfo;
1130+
mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64;
1131+
kr = mach_vm_region_recurse(mach_task_self(), &address, &vmsize, &depth,
1132+
(vm_region_info_t)&vminfo, &count);
1133+
1134+
if (kr == KERN_DENIED) {
1135+
Report(
1136+
"ERROR: mach_vm_region_recurse got KERN_DENIED when printing memory "
1137+
"map.\n");
1138+
Report(
1139+
"HINT: Check whether mach_vm_region_recurse is allowed by "
1140+
"sandbox.\n");
1141+
}
1142+
1143+
if (kr == KERN_SUCCESS && address < max_vm_address) {
1144+
if (last + lastsz == address) {
1145+
// This region is contiguous with the last; merge together.
1146+
lastsz += vmsize;
1147+
} else {
1148+
if (lastsz)
1149+
Printf("|| `[%p, %p]` || size=0x%016" PRIx64 " ||\n", last,
1150+
last + lastsz, lastsz);
1151+
1152+
last = address;
1153+
lastsz = vmsize;
1154+
}
1155+
address += vmsize;
1156+
} else {
1157+
// We've reached the end of the memory map. Print the last remaining
1158+
// region, if there is one.
1159+
if (lastsz)
1160+
Printf("|| `[%p, %p]` || size=0x%016" PRIx64 " ||\n", last,
1161+
last + lastsz, lastsz);
1162+
1163+
break;
1164+
}
1165+
}
1166+
}
1167+
1168+
static void ReportShadowAllocFail(uptr shadow_size_bytes, uptr alignment) {
1169+
Report(
1170+
"FATAL: Failed to allocate shadow memory. Tried to allocate %p bytes "
1171+
"(alignment=%p).\n",
1172+
shadow_size_bytes, alignment);
1173+
PrintVmmap();
1174+
}
1175+
11091176
char **GetArgv() {
11101177
return *_NSGetArgv();
11111178
}
@@ -1213,10 +1280,11 @@ uptr MapDynamicShadow(uptr shadow_size_bytes, uptr shadow_scale,
12131280
if (new_max_vm < max_occupied_addr) {
12141281
Report("Unable to find a memory range for dynamic shadow.\n");
12151282
Report(
1216-
"space_size = %p, largest_gap_found = %p, max_occupied_addr = %p, "
1217-
"new_max_vm = %p\n",
1218-
(void *)space_size, (void *)largest_gap_found,
1219-
(void *)max_occupied_addr, (void *)new_max_vm);
1283+
"\tspace_size = %p\n\tlargest_gap_found = %p\n\tmax_occupied_addr "
1284+
"= %p\n\tnew_max_vm = %p\n",
1285+
(void*)space_size, (void*)largest_gap_found, (void*)max_occupied_addr,
1286+
(void*)new_max_vm);
1287+
ReportShadowAllocFail(shadow_size_bytes, alignment);
12201288
CHECK(0 && "cannot place shadow");
12211289
}
12221290
RestrictMemoryToMaxAddress(new_max_vm);
@@ -1227,6 +1295,7 @@ uptr MapDynamicShadow(uptr shadow_size_bytes, uptr shadow_scale,
12271295
nullptr, nullptr);
12281296
if (shadow_start == 0) {
12291297
Report("Unable to find a memory range after restricting VM.\n");
1298+
ReportShadowAllocFail(shadow_size_bytes, alignment);
12301299
CHECK(0 && "cannot place shadow after restricting vm");
12311300
}
12321301
}
@@ -1242,26 +1311,19 @@ uptr MapDynamicShadowAndAliases(uptr shadow_size, uptr alias_size,
12421311
}
12431312

12441313
uptr FindAvailableMemoryRange(uptr size, uptr alignment, uptr left_padding,
1245-
uptr *largest_gap_found,
1246-
uptr *max_occupied_addr) {
1247-
typedef vm_region_submap_short_info_data_64_t RegionInfo;
1248-
enum { kRegionInfoSize = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 };
1249-
// Start searching for available memory region past PAGEZERO, which is
1250-
// 4KB on 32-bit and 4GB on 64-bit.
1251-
mach_vm_address_t start_address =
1252-
(SANITIZER_WORDSIZE == 32) ? 0x000000001000 : 0x000100000000;
1253-
1314+
uptr* largest_gap_found,
1315+
uptr* max_occupied_addr) {
12541316
const mach_vm_address_t max_vm_address = GetMaxVirtualAddress() + 1;
1255-
mach_vm_address_t address = start_address;
1256-
mach_vm_address_t free_begin = start_address;
1317+
mach_vm_address_t address = GAP_SEARCH_START_ADDRESS;
1318+
mach_vm_address_t free_begin = GAP_SEARCH_START_ADDRESS;
12571319
kern_return_t kr = KERN_SUCCESS;
12581320
if (largest_gap_found) *largest_gap_found = 0;
12591321
if (max_occupied_addr) *max_occupied_addr = 0;
12601322
while (kr == KERN_SUCCESS) {
12611323
mach_vm_size_t vmsize = 0;
12621324
natural_t depth = 0;
1263-
RegionInfo vminfo;
1264-
mach_msg_type_number_t count = kRegionInfoSize;
1325+
vm_region_submap_short_info_data_64_t vminfo;
1326+
mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64;
12651327
kr = mach_vm_region_recurse(mach_task_self(), &address, &vmsize, &depth,
12661328
(vm_region_info_t)&vminfo, &count);
12671329

lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OBJC_SOURCES := main.m
22

3-
CFLAGS_EXTRAS := -w
3+
CFLAGS_EXTRAS := -w -Wno-error=incompatible-pointer-types
44

55

66

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
C_SOURCES := main.c
2-
CFLAGS_EXTRAS := -std=c99
2+
CFLAGS_EXTRAS := -std=c99 -Wno-error=incompatible-pointer-types
33

44
include Makefile.rules

llvm/cmake/modules/LLVMConfig.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ set(LLVM_TARGETS_WITH_JIT @LLVM_TARGETS_WITH_JIT@)
3636

3737
set(LLVM_TARGET_TRIPLE "@LLVM_TARGET_TRIPLE@")
3838

39+
set(LLVM_TARGET_TRIPLE_ENV "@LLVM_TARGET_TRIPLE_ENV@")
40+
3941
set(LLVM_HOST_TRIPLE "@LLVM_HOST_TRIPLE@")
4042

4143
set(LLVM_ABI_BREAKING_CHECKS @LLVM_ABI_BREAKING_CHECKS@)

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,21 @@ class FunctionSamples {
10411041
return VirtualCallsiteTypeCounts[mapIRLocToProfileLoc(Loc)];
10421042
}
10431043

1044+
/// At location \p Loc, add a type sample for the given \p Type with
1045+
/// \p Count. This function uses saturating add which clamp the result to
1046+
/// maximum uint64_t (the counter type), and inserts the saturating add result
1047+
/// to map. Returns counter_overflow to caller if the actual result is larger
1048+
/// than maximum uint64_t.
1049+
sampleprof_error addTypeSamplesAt(const LineLocation &Loc, FunctionId Type,
1050+
uint64_t Count) {
1051+
auto &TypeCounts = getTypeSamplesAt(Loc);
1052+
bool Overflowed = false;
1053+
TypeCounts[Type] = SaturatingMultiplyAdd(Count, /* Weight= */ (uint64_t)1,
1054+
TypeCounts[Type], &Overflowed);
1055+
return Overflowed ? sampleprof_error::counter_overflow
1056+
: sampleprof_error::success;
1057+
}
1058+
10441059
/// Scale \p Other sample counts by \p Weight and add the scaled result to the
10451060
/// type samples for \p Loc. Under the hoold, the caller-provided \p Loc will
10461061
/// be un-drifted before the type sample lookup if possible.

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_FunnelShift(SDNode *N) {
16311631
// type.
16321632
if (IsFSHR)
16331633
Amt = DAG.getNode(ISD::ADD, DL, AmtVT, Amt,
1634-
DAG.getConstant(NewBits - OldBits, DL, VT));
1634+
DAG.getConstant(NewBits - OldBits, DL, AmtVT));
16351635

16361636
return DAG.getNode(Opcode, DL, VT, Hi, Lo, Amt);
16371637
}

llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <cstdint>
2727

2828
using namespace llvm;
29+
using namespace llvm::MCD;
2930

3031
#define DEBUG_TYPE "bpf-disassembler"
3132

llvm/lib/Target/CSKY/Disassembler/CSKYDisassembler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/Support/Endian.h"
2727

2828
using namespace llvm;
29+
using namespace llvm::MCD;
2930

3031
#define DEBUG_TYPE "csky-disassembler"
3132

llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define DEBUG_TYPE "hexagon-disassembler"
3535

3636
using namespace llvm;
37+
using namespace llvm::MCD;
3738
using namespace Hexagon;
3839

3940
using DecodeStatus = MCDisassembler::DecodeStatus;

0 commit comments

Comments
 (0)