Skip to content

Commit 73229a9

Browse files
author
git apple-llvm automerger
committed
Merge commit '1827998c4799' from apple/stable/20210107 into swift/main
2 parents af1ece4 + 1827998 commit 73229a9

File tree

77 files changed

+575
-290
lines changed

Some content is hidden

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

77 files changed

+575
-290
lines changed

clang/lib/Basic/TargetInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
6767
// From the glibc documentation, on GNU systems, malloc guarantees 16-byte
6868
// alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
6969
// https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
70-
// This alignment guarantee also applies to Windows and Android.
70+
// This alignment guarantee also applies to Windows and Android. On Darwin,
71+
// the alignment is 16 bytes on both 64-bit and 32-bit systems.
7172
if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
7273
NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
74+
else if (T.isOSDarwin())
75+
NewAlign = 128;
7376
else
7477
NewAlign = 0; // Infer from basic type alignment.
7578
HalfWidth = 16;

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,8 @@ struct NullReturnState {
18001800
// If we've got a scalar return, build a phi.
18011801
if (result.isScalar()) {
18021802
// Derive the null-initialization value.
1803-
llvm::Constant *null = CGF.CGM.EmitNullConstant(resultType);
1803+
llvm::Value *null =
1804+
CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(resultType), resultType);
18041805

18051806
// If no join is necessary, just flow out.
18061807
if (!contBB) return RValue::get(null);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %clang_cc1 -triple arm64e-apple-ios15.0.0 -emit-llvm-bc -fobjc-arc -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
2+
3+
// rdar://73361264
4+
5+
@protocol NSObject
6+
@end
7+
8+
@interface NSObject <NSObject>
9+
@end
10+
11+
@interface WidgetTester : NSObject
12+
@end
13+
14+
@implementation WidgetTester
15+
16+
typedef struct {
17+
NSObject* impl;
18+
} widget_t;
19+
20+
- (_Bool)withWidget:(widget_t)widget {
21+
return 0;
22+
}
23+
24+
- (_Bool)testWidget:(widget_t)widget {
25+
return [self withWidget:widget];
26+
}
27+
28+
@end
29+
30+
// CHECK-LABEL: msgSend.call:
31+
// CHECK: [[CALL:%[^ ]+]] = call i1 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to
32+
// CHECK-NEXT: br label %msgSend.cont
33+
34+
// CHECK-LABEL: msgSend.null-receiver:
35+
// CHECK: br label %msgSend.cont
36+
37+
// CHECK-LABEL: msgSend.cont:
38+
// CHECK-NEXT: {{%[^ ]+}} = phi i1 [ [[CALL]], %msgSend.call ], [ false, %msgSend.null-receiver ]

clang/test/Preprocessor/init-aarch64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@
532532
// AARCH64-DARWIN: #define __WINT_WIDTH__ 32
533533
// AARCH64-DARWIN: #define __aarch64__ 1
534534

535+
// RUN: %clang_cc1 -E -dM -triple=aarch64-apple-ios7.0 -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN-CXX %s
536+
// AARCH64-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
537+
535538
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
536539

537540
// AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64

clang/test/Preprocessor/init-arm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@
196196
// ARM:#define __arm 1
197197
// ARM:#define __arm__ 1
198198

199+
// RUN: %clang_cc1 -E -dM -triple=armv7-apple-ios7.0 -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix ARM-DARWIN-CXX %s
200+
// ARM-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
201+
199202
// RUN: %clang_cc1 -dM -ffreestanding -triple arm-none-none -target-abi apcs-gnu -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-APCS-GNU %s
200203
// ARM-APCS-GNU: #define __INTPTR_TYPE__ int
201204
// ARM-APCS-GNU: #define __PTRDIFF_TYPE__ int

lldb/bindings/interface/SBTarget.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,16 @@ public:
958958
lldb::addr_t
959959
GetStackRedZoneSize();
960960

961+
%feature("docstring", "
962+
Returns true if the module has been loaded in this `SBTarget`.
963+
A module can be loaded either by the dynamic loader or by being manually
964+
added to the target (see `SBTarget.AddModule` and the `target module add` command).
965+
966+
:rtype: bool
967+
") IsLoaded;
968+
bool
969+
IsLoaded (const lldb::SBModule &module) const;
970+
961971
lldb::SBLaunchInfo
962972
GetLaunchInfo () const;
963973

lldb/include/lldb/API/SBTarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ class LLDB_API SBTarget {
845845

846846
lldb::addr_t GetStackRedZoneSize();
847847

848+
bool IsLoaded(const lldb::SBModule &module) const;
849+
848850
lldb::SBLaunchInfo GetLaunchInfo() const;
849851

850852
void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);

lldb/source/API/SBTarget.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,21 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() {
24702470
return 0;
24712471
}
24722472

2473+
bool SBTarget::IsLoaded(const SBModule &module) const {
2474+
LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &),
2475+
module);
2476+
2477+
TargetSP target_sp(GetSP());
2478+
if (!target_sp)
2479+
return false;
2480+
2481+
ModuleSP module_sp(module.GetSP());
2482+
if (!module_sp)
2483+
return false;
2484+
2485+
return module_sp->IsLoadedInTarget(target_sp.get());
2486+
}
2487+
24732488
lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
24742489
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
24752490

@@ -2742,6 +2757,8 @@ void RegisterMethods<SBTarget>(Registry &R) {
27422757
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
27432758
(const char *, const lldb::SBExpressionOptions &));
27442759
LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
2760+
LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
2761+
(const lldb::SBModule &));
27452762
LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
27462763
LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
27472764
(const lldb::SBLaunchInfo &));

lldb/source/Host/macosx/objcxx/Host.mm

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include <asl.h>
4040
#include <crt_externs.h>
41+
#include <dlfcn.h>
4142
#include <grp.h>
4243
#include <libproc.h>
4344
#include <pwd.h>
@@ -1108,6 +1109,55 @@ static Status LaunchProcessPosixSpawn(const char *exe_path,
11081109
}
11091110
}
11101111

1112+
// Don't set the binpref if a shell was provided. After all, that's only
1113+
// going to affect what version of the shell is launched, not what fork of
1114+
// the binary is launched. We insert "arch --arch <ARCH> as part of the
1115+
// shell invocation to do that job on OSX.
1116+
if (launch_info.GetShell() == FileSpec()) {
1117+
const ArchSpec &arch_spec = launch_info.GetArchitecture();
1118+
cpu_type_t cpu_type = arch_spec.GetMachOCPUType();
1119+
cpu_type_t cpu_subtype = arch_spec.GetMachOCPUSubType();
1120+
const bool set_cpu_type =
1121+
cpu_type != 0 && cpu_type != static_cast<cpu_type_t>(UINT32_MAX) &&
1122+
cpu_type != static_cast<cpu_type_t>(LLDB_INVALID_CPUTYPE);
1123+
const bool set_cpu_subtype =
1124+
cpu_subtype != 0 &&
1125+
cpu_subtype != static_cast<cpu_subtype_t>(UINT32_MAX) &&
1126+
cpu_subtype != CPU_SUBTYPE_X86_64_H;
1127+
if (set_cpu_type) {
1128+
size_t ocount = 0;
1129+
typedef int (*posix_spawnattr_setarchpref_np_t)(
1130+
posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t *);
1131+
posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn =
1132+
(posix_spawnattr_setarchpref_np_t)dlsym(
1133+
RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
1134+
if (set_cpu_subtype && posix_spawnattr_setarchpref_np_fn) {
1135+
error.SetError((*posix_spawnattr_setarchpref_np_fn)(
1136+
&attr, 1, &cpu_type, &cpu_subtype, &ocount),
1137+
eErrorTypePOSIX);
1138+
if (error.Fail())
1139+
LLDB_LOG(log,
1140+
"error: {0}, ::posix_spawnattr_setarchpref_np ( &attr, 1, "
1141+
"cpu_type = {1:x}, cpu_subtype = {1:x}, count => {2} )",
1142+
error, cpu_type, cpu_subtype, ocount);
1143+
1144+
if (error.Fail() || ocount != 1)
1145+
return error;
1146+
} else {
1147+
error.SetError(
1148+
::posix_spawnattr_setbinpref_np(&attr, 1, &cpu_type, &ocount),
1149+
eErrorTypePOSIX);
1150+
if (error.Fail())
1151+
LLDB_LOG(log,
1152+
"error: {0}, ::posix_spawnattr_setbinpref_np ( &attr, 1, "
1153+
"cpu_type = {1:x}, count => {2} )",
1154+
error, cpu_type, ocount);
1155+
if (error.Fail() || ocount != 1)
1156+
return error;
1157+
}
1158+
}
1159+
}
1160+
11111161
const char *tmp_argv[2];
11121162
char *const *argv = const_cast<char *const *>(
11131163
launch_info.GetArguments().GetConstArgumentVector());

lldb/source/Utility/ArchSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ static const ArchDefinitionEntry g_macho_arch_entries[] = {
286286
{ArchSpec::eCore_arm_armv7m, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7M, UINT32_MAX, SUBTYPE_MASK},
287287
{ArchSpec::eCore_arm_armv7em, llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_SUBTYPE_ARM_V7EM, UINT32_MAX, SUBTYPE_MASK},
288288
{ArchSpec::eCore_arm_arm64e, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64E, UINT32_MAX, SUBTYPE_MASK},
289-
{ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_V8, UINT32_MAX, SUBTYPE_MASK},
290289
{ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_ALL, UINT32_MAX, SUBTYPE_MASK},
290+
{ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_SUBTYPE_ARM64_V8, UINT32_MAX, SUBTYPE_MASK},
291291
{ArchSpec::eCore_arm_arm64, llvm::MachO::CPU_TYPE_ARM64, 13, UINT32_MAX, SUBTYPE_MASK},
292292
{ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 0, UINT32_MAX, SUBTYPE_MASK},
293293
{ArchSpec::eCore_arm_arm64_32, llvm::MachO::CPU_TYPE_ARM64_32, 1, UINT32_MAX, SUBTYPE_MASK},

0 commit comments

Comments
 (0)