Skip to content

Commit 53dcbc5

Browse files
author
git apple-llvm automerger
committed
Merge commit 'cae2a36d480d' from llvm.org/main into experimental/cas/main
2 parents c5a0344 + cae2a36 commit 53dcbc5

File tree

23 files changed

+851
-311
lines changed

23 files changed

+851
-311
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ bool BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
20382038
MCInst *PrevInstr = PrevBB->getLastNonPseudoInstr();
20392039
assert(PrevInstr && "no previous instruction for a fall through");
20402040
if (MIB->isUnconditionalBranch(Instr) &&
2041+
!MIB->isIndirectBranch(*PrevInstr) &&
20412042
!MIB->isUnconditionalBranch(*PrevInstr) &&
20422043
!MIB->getConditionalTailCall(*PrevInstr) &&
20432044
!MIB->isReturn(*PrevInstr)) {

bolt/test/X86/unreachable-jmp.s

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This checks that we don't create an invalid CFG when there is an
2+
# unreachable direct jump right after an indirect one.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
7+
# RUN: %s -o %t.o
8+
# RUN: link_fdata %s %t.o %t.fdata
9+
# RUN: llvm-strip --strip-unneeded %t.o
10+
# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q -nostdlib
11+
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata \
12+
# RUN: --eliminate-unreachable --print-cfg | FileCheck %s
13+
14+
.globl _start
15+
.type _start, %function
16+
_start:
17+
.cfi_startproc
18+
# FDATA: 0 [unknown] 0 1 _start 0 0 1
19+
push %rbp
20+
mov %rsp, %rbp
21+
push %rbx
22+
push %r14
23+
subq $0x20, %rsp
24+
movq %rdi, %rcx
25+
b:
26+
jmpq *JUMP_TABLE(,%rcx,8)
27+
# FDATA: 1 _start #b# 1 _start #hotpath# 0 20
28+
# Unreachable direct jump here. Our CFG should still make sense and properly
29+
# place this instruction in a new basic block.
30+
jmp .lbb2
31+
.lbb1: je .lexit
32+
.lbb2:
33+
xorq %rax, %rax
34+
addq $0x20, %rsp
35+
pop %r14
36+
pop %rbx
37+
pop %rbp
38+
ret
39+
hotpath:
40+
movq $2, %rax
41+
addq $0x20, %rsp
42+
pop %r14
43+
pop %rbx
44+
pop %rbp
45+
ret
46+
.lexit:
47+
movq $1, %rax
48+
addq $0x20, %rsp
49+
pop %r14
50+
pop %rbx
51+
pop %rbp
52+
ret
53+
.cfi_endproc
54+
.size _start, .-_start
55+
56+
.rodata
57+
.globl JUMP_TABLE
58+
JUMP_TABLE:
59+
.quad .lbb1
60+
.quad .lbb2
61+
.quad hotpath
62+
63+
# No basic blocks above should have 4 successors! That is a bug.
64+
# CHECK-NOT: Successors: {{.*}} (mispreds: 0, count: 20), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0)
65+
# Check successful removal of stray direct jmp
66+
# CHECK: UCE removed 1 block

compiler-rt/lib/fuzzer/FuzzerDriver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ int MinimizeCrashInputInternalStep(Fuzzer *F, InputCorpus *Corpus) {
501501
F->MinimizeCrashLoop(U);
502502
Printf("INFO: Done MinimizeCrashInputInternalStep, no crashes found\n");
503503
exit(0);
504-
return 0;
505504
}
506505

507506
void Merge(Fuzzer *F, FuzzingOptions &Options,

compiler-rt/lib/orc/macho_platform.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ Error MachOPlatformRuntimeState::deregisterEHFrames(
859859

860860
Error MachOPlatformRuntimeState::registerObjCRegistrationObjects(
861861
JITDylibState &JDS) {
862+
ORC_RT_DEBUG(printdbg("Registering Objective-C / Swift metadata.\n"));
863+
862864
if (!_objc_map_images || !_objc_load_image)
863865
return make_error<StringError>(
864866
"Could not register Objective-C / Swift metadata: _objc_map_images / "

compiler-rt/lib/scudo/standalone/primary64.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,14 @@ template <typename Config> class SizeClassAllocator64 {
747747
}
748748
// TODO: Consider allocating MemMap in init().
749749
if (!Region->MemMap.isAllocated()) {
750-
Region->MemMap = ReservedMemory.dispatch(
751-
getRegionBaseByClassId(ClassId), RegionSize);
750+
// TODO: Ideally, a region should reserve RegionSize because the memory
751+
// between `RegionBeg` and region base is still belong to a region and
752+
// it's just not used. In order to make it work on every platform (some
753+
// of them don't support `remap()` across the unused range), dispatch
754+
// from `RegionBeg` for now.
755+
const uptr ReserveSize =
756+
RegionSize - (RegionBeg - getRegionBaseByClassId(ClassId));
757+
Region->MemMap = ReservedMemory.dispatch(RegionBeg, ReserveSize);
752758
}
753759
DCHECK(Region->MemMap.isAllocated());
754760

compiler-rt/test/lit.common.cfg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ def get_ios_commands_dir():
403403
if osx_version >= (10, 11):
404404
config.available_features.add('osx-autointerception')
405405
config.available_features.add('osx-ld64-live_support')
406-
if osx_version >= (10, 15):
407-
config.available_features.add('osx-swift-runtime')
406+
if osx_version >= (13, 1):
407+
config.available_features.add('jit-compatible-osx-swift-runtime')
408408
except subprocess.CalledProcessError:
409409
pass
410410

compiler-rt/test/lsan/TestCases/lsan_annotations.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
#include <sanitizer/lsan_interface.h>
66
#include <stdlib.h>
77

8-
int *x, *y;
8+
int *x, *y, *z;
99

1010
int main() {
1111
x = new int;
1212
__lsan_ignore_object(x);
1313

14+
z = new int[1000000]; // Large enough for the secondary allocator.
15+
__lsan_ignore_object(z);
16+
1417
{
1518
__lsan::ScopedDisabler disabler;
1619
y = new int;
1720
}
1821

19-
x = y = nullptr;
22+
x = y = z = nullptr;
2023
return 0;
2124
}
Lines changed: 112 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,129 @@
11
# RUN: %clang -c -o %t %s
22
# RUN: %llvm_jitlink -preload /usr/lib/swift/libswiftCore.dylib %t
33

4-
# REQUIRES: osx-swift-runtime
4+
# REQUIRES: jit-compatible-osx-swift-runtime
55

66
# Check that _typeByName is able to find a type registered by metadata in
77
# the __swift5_types section.
88

9-
.section __TEXT,__text,regular,pure_instructions
10-
.globl _main
11-
.p2align 4, 0x90
9+
.section __TEXT,__text,regular,pure_instructions
10+
.build_version macos, 14, 0 sdk_version 14, 0
11+
.globl _main
12+
.p2align 4, 0x90
1213
_main:
13-
.cfi_startproc
14-
pushq %rbp
15-
.cfi_def_cfa_offset 16
16-
.cfi_offset %rbp, -16
17-
movq %rsp, %rbp
18-
.cfi_def_cfa_register %rbp
19-
# Constant String for "4Test3FooV"
20-
movabsq $8018152761824990260, %rdi
21-
movabsq $-1585267068834392465, %rsi
22-
callq _$ss11_typeByNameyypXpSgSSF
23-
xorl %edi, %edi
24-
testq %rax, %rax
25-
sete %dil
26-
callq _exit
27-
.cfi_endproc
28-
29-
.private_extern _$s4Test3FooVMa
30-
.globl _$s4Test3FooVMa
31-
.p2align 4, 0x90
14+
.cfi_startproc
15+
pushq %rbp
16+
.cfi_def_cfa_offset 16
17+
.cfi_offset %rbp, -16
18+
movq %rsp, %rbp
19+
.cfi_def_cfa_register %rbp
20+
# Constant String for "4Test3FooV"
21+
movabsq $8018152761824990260, %rdi
22+
movabsq $-1585267068834392465, %rsi
23+
callq _$ss11_typeByNameyypXpSgSSF
24+
xorl %edi, %edi
25+
testq %rax, %rax
26+
sete %dil
27+
callq _exit
28+
.cfi_endproc
29+
30+
.private_extern _$s4Test3FooVACycfC
31+
.globl _$s4Test3FooVACycfC
32+
.p2align 4, 0x90
33+
_$s4Test3FooVACycfC:
34+
pushq %rbp
35+
movq %rsp, %rbp
36+
popq %rbp
37+
retq
38+
39+
.private_extern _$s4Test3FooVMa
40+
.globl _$s4Test3FooVMa
41+
.p2align 4, 0x90
3242
_$s4Test3FooVMa:
33-
leaq _$s4Test3FooVMf+8(%rip), %rax
34-
xorl %edx, %edx
35-
retq
36-
37-
.section __TEXT,__const
38-
l___unnamed_1:
39-
.asciz "Test"
40-
41-
.private_extern _$s4TestMXM
42-
.globl _$s4TestMXM
43-
.weak_definition _$s4TestMXM
44-
.p2align 2
43+
leaq _$s4Test3FooVMf+8(%rip), %rax
44+
xorl %edx, %edx
45+
retq
46+
47+
.section __TEXT,__swift5_entry,regular,no_dead_strip
48+
.p2align 2
49+
l_entry_point:
50+
.long _main-l_entry_point
51+
.long 0
52+
53+
.section __TEXT,__const
54+
l_.str.4.Test:
55+
.asciz "Test"
56+
57+
.private_extern _$s4TestMXM
58+
.globl _$s4TestMXM
59+
.weak_definition _$s4TestMXM
60+
.p2align 2
4561
_$s4TestMXM:
46-
.long 0
47-
.long 0
48-
.long (l___unnamed_1-_$s4TestMXM)-8
62+
.long 0
63+
.long 0
64+
.long (l_.str.4.Test-_$s4TestMXM)-8
4965

50-
l___unnamed_2:
51-
.asciz "Foo"
66+
l_.str.3.Foo:
67+
.asciz "Foo"
5268

53-
.private_extern _$s4Test3FooVMn
54-
.globl _$s4Test3FooVMn
55-
.p2align 2
69+
.private_extern _$s4Test3FooVMn
70+
.globl _$s4Test3FooVMn
71+
.p2align 2
5672
_$s4Test3FooVMn:
57-
.long 81
58-
.long (_$s4TestMXM-_$s4Test3FooVMn)-4
59-
.long (l___unnamed_2-_$s4Test3FooVMn)-8
60-
.long (_$s4Test3FooVMa-_$s4Test3FooVMn)-12
61-
.long (_$s4Test3FooVMF-_$s4Test3FooVMn)-16
62-
.long 0
63-
.long 2
64-
65-
.section __DATA,__const
66-
.p2align 3
73+
.long 81
74+
.long (_$s4TestMXM-_$s4Test3FooVMn)-4
75+
.long (l_.str.3.Foo-_$s4Test3FooVMn)-8
76+
.long (_$s4Test3FooVMa-_$s4Test3FooVMn)-12
77+
.long (_$s4Test3FooVMF-_$s4Test3FooVMn)-16
78+
.long 0
79+
.long 2
80+
81+
.section __DATA,__const
82+
.p2align 3
6783
_$s4Test3FooVMf:
68-
.quad _$sytWV
69-
.quad 512
70-
.quad _$s4Test3FooVMn
71-
72-
.private_extern "_symbolic _____ 4Test3FooV"
73-
.section __TEXT,__swift5_typeref,regular,no_dead_strip
74-
.globl "_symbolic _____ 4Test3FooV"
75-
.weak_definition "_symbolic _____ 4Test3FooV"
76-
.p2align 1
84+
.quad _$sytWV
85+
.quad 512
86+
.quad _$s4Test3FooVMn
87+
88+
.private_extern "_symbolic _____ 4Test3FooV"
89+
.section __TEXT,__swift5_typeref
90+
.globl "_symbolic _____ 4Test3FooV"
91+
.weak_definition "_symbolic _____ 4Test3FooV"
92+
.p2align 1
7793
"_symbolic _____ 4Test3FooV":
78-
.byte 1
79-
.long (_$s4Test3FooVMn-"_symbolic _____ 4Test3FooV")-1
80-
.byte 0
94+
.byte 1
95+
.long (_$s4Test3FooVMn-"_symbolic _____ 4Test3FooV")-1
96+
.byte 0
8197

82-
.section __TEXT,__swift5_fieldmd,regular,no_dead_strip
83-
.p2align 2
98+
.section __TEXT,__swift5_fieldmd
99+
.p2align 2
84100
_$s4Test3FooVMF:
85-
.long "_symbolic _____ 4Test3FooV"-_$s4Test3FooVMF
86-
.long 0
87-
.short 0
88-
.short 12
89-
.long 0
90-
91-
.section __TEXT,__swift5_types,regular,no_dead_strip
92-
.p2align 2
93-
l_type_metadata_table:
94-
.long _$s4Test3FooVMn-l_type_metadata_table
101+
.long "_symbolic _____ 4Test3FooV"-_$s4Test3FooVMF
102+
.long 0
103+
.short 0
104+
.short 12
105+
.long 0
106+
107+
.section __TEXT,__swift5_types
108+
.p2align 2
109+
l_$s4Test3FooVHn:
110+
.long _$s4Test3FooVMn-l_$s4Test3FooVHn
111+
112+
.private_extern ___swift_reflection_version
113+
.section __TEXT,__const
114+
.globl ___swift_reflection_version
115+
.weak_definition ___swift_reflection_version
116+
.p2align 1
117+
___swift_reflection_version:
118+
.short 3
119+
120+
.section __DATA,__objc_imageinfo,regular,no_dead_strip
121+
L_OBJC_IMAGE_INFO:
122+
.long 0
123+
.long 84477760
124+
125+
.globl _$s4Test3FooVN
126+
.private_extern _$s4Test3FooVN
127+
.alt_entry _$s4Test3FooVN
128+
.set _$s4Test3FooVN, _$s4Test3FooVMf+8
129+
.subsections_via_symbols

lldb/examples/python/crashlog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,12 +1111,17 @@ def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result)
11111111
launch_info.SetProcessPluginName("ScriptedProcess")
11121112
launch_info.SetScriptedProcessClassName("crashlog_scripted_process.CrashLogScriptedProcess")
11131113
launch_info.SetScriptedProcessDictionary(structured_data)
1114+
launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
1115+
11141116
error = lldb.SBError()
11151117
process = target.Launch(launch_info, error)
11161118

11171119
if not process or error.Fail():
11181120
raise InteractiveCrashLogException("couldn't launch Scripted Process", error)
11191121

1122+
process.GetScriptedImplementation().set_crashlog(crashlog)
1123+
process.Continue()
1124+
11201125
if not options.skip_status:
11211126
@contextlib.contextmanager
11221127
def synchronous(debugger):

0 commit comments

Comments
 (0)