Skip to content

Commit c4a7948

Browse files
authored
merge main into amd-staging (llvm#3352)
2 parents ff544d9 + fae7ff5 commit c4a7948

File tree

99 files changed

+8767
-556
lines changed

Some content is hidden

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

99 files changed

+8767
-556
lines changed

clang/cmake/caches/Release.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ if (LLVM_RELEASE_ENABLE_LTO)
102102
# FIXME: We can't use LLVM_ENABLE_LTO=Thin here, because it causes the CMake
103103
# step for the libcxx build to fail. CMAKE_INTERPROCEDURAL_OPTIMIZATION does
104104
# enable ThinLTO, though.
105-
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DLLVM_ENABLE_LLD=ON" CACHE STRING "")
105+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_FATLTO=ON" CACHE STRING "")
106106
endif()
107107

108108
# Stage 1 Common Config
@@ -144,3 +144,7 @@ set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
144144
set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
145145

146146
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)
147+
if (LLVM_RELEASE_ENABLE_LTO)
148+
set_final_stage_var(LLVM_ENABLE_FATLTO "ON" BOOL)
149+
set_final_stage_var(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/release_cpack_pre_build_strip_lto.cmake" STRING)
150+
endif()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
file(GLOB files ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/lib/*.a)
2+
3+
foreach(file ${files})
4+
execute_process(COMMAND ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/bin/llvm-strip --no-strip-all -R .llvm.lto ${file})
5+
endforeach()

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,7 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
12981298
decl->getDeclKindName());
12991299
break;
13001300

1301+
case Decl::CXXConversion:
13011302
case Decl::CXXMethod:
13021303
case Decl::Function: {
13031304
auto *fd = cast<FunctionDecl>(decl);
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// RUN: %clang_cc1 -std=c++11 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -std=c++11 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5+
// RUN: %clang_cc1 -std=c++11 -triple aarch64-none-linux-android21 -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7+
8+
struct inline_operator {
9+
operator int() const { return 987; }
10+
11+
int operator+(inline_operator) { return 666; }
12+
};
13+
14+
struct out_of_line_operator {
15+
operator int();
16+
};
17+
18+
out_of_line_operator::operator int() { return 123; }
19+
20+
void test() {
21+
int x = 42;
22+
23+
inline_operator i;
24+
x = i;
25+
26+
out_of_line_operator o;
27+
x = o;
28+
}
29+
30+
// CIR: cir.func dso_local @_ZN20out_of_line_operatorcviEv(%[[THIS_ARG:.+]]: !cir.ptr<!rec_out_of_line_operator>{{.*}}) -> !s32i
31+
// CIR: %[[THIS_ALLOCA:.+]] = cir.alloca !cir.ptr<!rec_out_of_line_operator>, !cir.ptr<!cir.ptr<!rec_out_of_line_operator>>, ["this", init]
32+
// CIR: %[[RETVAL:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
33+
// CIR: cir.store %[[THIS_ARG]], %[[THIS_ALLOCA]] : !cir.ptr<!rec_out_of_line_operator>, !cir.ptr<!cir.ptr<!rec_out_of_line_operator>>
34+
// CIR: %[[THIS_LOAD:.+]] = cir.load %[[THIS_ALLOCA]] : !cir.ptr<!cir.ptr<!rec_out_of_line_operator>>, !cir.ptr<!rec_out_of_line_operator>
35+
// CIR: %[[CONST_123:.+]] = cir.const #cir.int<123> : !s32i
36+
// CIR: cir.store %[[CONST_123]], %[[RETVAL]] : !s32i, !cir.ptr<!s32i>
37+
// CIR: %[[RET_LOAD:.+]] = cir.load %[[RETVAL]] : !cir.ptr<!s32i>, !s32i
38+
// CIR: cir.return %[[RET_LOAD]] : !s32i
39+
// CIR: }
40+
41+
// CIR: cir.func comdat linkonce_odr @_ZNK15inline_operatorcviEv(%[[INLINE_THIS_ARG:.+]]: !cir.ptr<!rec_inline_operator>{{.*}}) -> !s32i
42+
// CIR: %[[INLINE_THIS_ALLOCA:.+]] = cir.alloca !cir.ptr<!rec_inline_operator>, !cir.ptr<!cir.ptr<!rec_inline_operator>>, ["this", init]
43+
// CIR: %[[INLINE_RETVAL:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
44+
// CIR: cir.store %[[INLINE_THIS_ARG]], %[[INLINE_THIS_ALLOCA]] : !cir.ptr<!rec_inline_operator>, !cir.ptr<!cir.ptr<!rec_inline_operator>>
45+
// CIR: %[[INLINE_THIS_LOAD:.+]] = cir.load %[[INLINE_THIS_ALLOCA]] : !cir.ptr<!cir.ptr<!rec_inline_operator>>, !cir.ptr<!rec_inline_operator>
46+
// CIR: %[[CONST_987:.+]] = cir.const #cir.int<987> : !s32i
47+
// CIR: cir.store %[[CONST_987]], %[[INLINE_RETVAL]] : !s32i, !cir.ptr<!s32i>
48+
// CIR: %[[INLINE_RET_LOAD:.+]] = cir.load %[[INLINE_RETVAL]] : !cir.ptr<!s32i>, !s32i
49+
// CIR: cir.return %[[INLINE_RET_LOAD]] : !s32i
50+
// CIR: }
51+
52+
// CIR: cir.func dso_local @_Z4testv()
53+
// CIR: %[[X_ALLOCA:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
54+
// CIR: %[[I_ALLOCA:.+]] = cir.alloca {{.*}}, {{.*}}, ["i"]
55+
// CIR: %[[O_ALLOCA:.+]] = cir.alloca {{.*}}, {{.*}}, ["o"]
56+
// CIR: %[[CONST_42:.+]] = cir.const #cir.int<42> : !s32i
57+
// CIR: cir.store align(4) %[[CONST_42]], %[[X_ALLOCA]] : !s32i, !cir.ptr<!s32i>
58+
// CIR: %[[INLINE_CALL:.+]] = cir.call @_ZNK15inline_operatorcviEv(%[[I_ALLOCA]]) : ({{.*}}) -> !s32i
59+
// CIR: cir.store align(4) %[[INLINE_CALL]], %[[X_ALLOCA]] : !s32i, !cir.ptr<!s32i>
60+
// CIR: %[[OUTLINE_CALL:.+]] = cir.call @_ZN20out_of_line_operatorcviEv(%[[O_ALLOCA]]) : ({{.*}}) -> !s32i
61+
// CIR: cir.store align(4) %[[OUTLINE_CALL]], %[[X_ALLOCA]] : !s32i, !cir.ptr<!s32i>
62+
// CIR: cir.return
63+
// CIR: }
64+
65+
// LLVM: define dso_local i32 @_ZN20out_of_line_operatorcviEv(ptr %[[PARAM0:.+]])
66+
// LLVM: %[[THIS_ALLOCA:.+]] = alloca ptr, i64 1
67+
// LLVM: %[[RETVAL:.+]] = alloca i32, i64 1
68+
// LLVM: store ptr %[[PARAM0]], ptr %[[THIS_ALLOCA]]
69+
// LLVM: %[[THIS_LOAD:.+]] = load ptr, ptr %[[THIS_ALLOCA]]
70+
// LLVM: store i32 123, ptr %[[RETVAL]]
71+
// LLVM: %[[RET_LOAD:.+]] = load i32, ptr %[[RETVAL]]
72+
// LLVM: ret i32 %[[RET_LOAD]]
73+
// LLVM: }
74+
75+
// LLVM: define linkonce_odr i32 @_ZNK15inline_operatorcviEv(ptr %[[INLINE_PARAM0:.+]])
76+
// LLVM: %[[INLINE_THIS_ALLOCA:.+]] = alloca ptr, i64 1
77+
// LLVM: %[[INLINE_RETVAL:.+]] = alloca i32, i64 1
78+
// LLVM: store ptr %[[INLINE_PARAM0]], ptr %[[INLINE_THIS_ALLOCA]]
79+
// LLVM: %[[INLINE_THIS_LOAD:.+]] = load ptr, ptr %[[INLINE_THIS_ALLOCA]]
80+
// LLVM: store i32 987, ptr %[[INLINE_RETVAL]]
81+
// LLVM: %[[INLINE_RET_LOAD:.+]] = load i32, ptr %[[INLINE_RETVAL]]
82+
// LLVM: ret i32 %[[INLINE_RET_LOAD]]
83+
// LLVM: }
84+
85+
// LLVM: define dso_local void @_Z4testv()
86+
// LLVM: %[[X_ALLOCA:.+]] = alloca i32, i64 1
87+
// LLVM: %[[I_ALLOCA:.+]] = alloca {{.*}}, i64 1
88+
// LLVM: %[[O_ALLOCA:.+]] = alloca {{.*}}, i64 1
89+
// LLVM: store i32 42, ptr %[[X_ALLOCA]]
90+
// LLVM: %[[INLINE_CALL:.+]] = call i32 @_ZNK15inline_operatorcviEv(ptr %[[I_ALLOCA]])
91+
// LLVM: store i32 %[[INLINE_CALL]], ptr %[[X_ALLOCA]]
92+
// LLVM: %[[OUTLINE_CALL:.+]] = call i32 @_ZN20out_of_line_operatorcviEv(ptr %[[O_ALLOCA]])
93+
// LLVM: store i32 %[[OUTLINE_CALL]], ptr %[[X_ALLOCA]]
94+
// LLVM: ret void
95+
// LLVM: }
96+
97+
// OGCG: define dso_local noundef i32 @_ZN20out_of_line_operatorcviEv(ptr {{.*}} %[[THIS_PARAM:.+]])
98+
// OGCG: entry:
99+
// OGCG: %[[THIS_ADDR:.+]] = alloca ptr
100+
// OGCG: store ptr %[[THIS_PARAM]], ptr %[[THIS_ADDR]]
101+
// OGCG: %[[THIS_LOAD:.+]] = load ptr, ptr %[[THIS_ADDR]]
102+
// OGCG: ret i32 123
103+
// OGCG: }
104+
105+
// OGCG: define dso_local void @_Z4testv()
106+
// OGCG: entry:
107+
// OGCG: %[[X_VAR:.+]] = alloca i32
108+
// OGCG: %[[I_VAR:.+]] = alloca {{.*}}
109+
// OGCG: %[[O_VAR:.+]] = alloca {{.*}}
110+
// OGCG: store i32 42, ptr %[[X_VAR]]
111+
// OGCG: %[[INLINE_CALL:.+]] = call noundef i32 @_ZNK15inline_operatorcviEv(ptr {{.*}} %[[I_VAR]])
112+
// OGCG: store i32 %[[INLINE_CALL]], ptr %[[X_VAR]]
113+
// OGCG: %[[OUTLINE_CALL:.+]] = call noundef i32 @_ZN20out_of_line_operatorcviEv(ptr {{.*}} %[[O_VAR]])
114+
// OGCG: store i32 %[[OUTLINE_CALL]], ptr %[[X_VAR]]
115+
// OGCG: ret void
116+
// OGCG: }
117+
118+
// OGCG: define linkonce_odr noundef i32 @_ZNK15inline_operatorcviEv(ptr {{.*}} %[[INLINE_THIS_PARAM:.+]])
119+
// OGCG: entry:
120+
// OGCG: %[[INLINE_THIS_ADDR:.+]] = alloca ptr
121+
// OGCG: store ptr %[[INLINE_THIS_PARAM]], ptr %[[INLINE_THIS_ADDR]]
122+
// OGCG: %[[INLINE_THIS_LOAD:.+]] = load ptr, ptr %[[INLINE_THIS_ADDR]]
123+
// OGCG: ret i32 987
124+
// OGCG: }

compiler-rt/test/asan/TestCases/Linux/long-object-path.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mkdir -p %T/a-long-directory-name-to-test-allocations-for-exceptions-in-_dl_lookup_symbol_x-since-glibc-2.27
2-
// RUN: %clangxx_asan -g %s -o %T/long-object-path
3-
// RUN: %run %T/a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../long-object-path
1+
// RUN: mkdir -p %t.a-long-directory-name-to-test-allocations-for-exceptions-in-_dl_lookup_symbol_x-since-glibc-2.27
2+
// RUN: %clangxx_asan -g %s -o %t.long-object-path
3+
// RUN: %run %t.a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../long-object-path
44

55
int main(void) {
66
return 0;

compiler-rt/test/fuzzer/afl-driver-stderr.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.
77
RUN: env -u AFL_DRIVER_STDERR_DUPLICATE_FILENAME %run %t-AFLDriverTest
88

99
; Test that specifying an invalid file causes a crash.
10-
RUN: env ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%T" not --crash %run %t-AFLDriverTest
10+
RUN: mkdir -p %t.dir
11+
RUN: env ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%t.dir" not --crash %run %t-AFLDriverTest
1112

1213
; Test that a file is created when specified as the duplicate stderr.
1314
RUN: env AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t %run %t-AFLDriverTest

compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// RUN: %clang %s -o %T/suffix-log-path_test-binary
1+
// RUN: rm -rf %t.dir
2+
// RUN: mkdir -p %t.dir
3+
// RUN: %clang %s -o %t.dir/suffix-log-path_test-binary
24

35
// The glob below requires bash.
46
// REQUIRES: shell
57

68
// Good log_path with suffix.
7-
// RUN: rm -f %T/sanitizer.log.*.txt
8-
// RUN: %env_tool_opts=log_path=%T/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %T/suffix-log-path_test-binary 2> %t.out
9-
// RUN: FileCheck %s < %T/sanitizer.log.suffix-log-path_test-binary.*.txt
9+
// RUN: %env_tool_opts=log_path=%t.dir/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %t.dir/suffix-log-path_test-binary 2> %t.out
10+
// RUN: FileCheck %s < %t.dir/sanitizer.log.suffix-log-path_test-binary.*.txt
1011

1112
// UNSUPPORTED: ios, android
1213

compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// RUN: %clangxx_xray -g -std=c++11 %s -o %t -fxray-modes=xray-fdr
2-
// RUN: rm -f fdr-inmemory-test-*
2+
// RUN: rm -rf %t.dir
3+
// RUN: mkdir -p %t.dir
4+
// RUN: cd %t.dir
35
// RUN: XRAY_OPTIONS="patch_premain=false xray_logfile_base=fdr-inmemory-test- \
46
// RUN: verbosity=1" \
57
// RUN: XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \
68
// RUN: %run %t 2>&1 | FileCheck %s
7-
// RUN: FILES=`find %T -name 'fdr-inmemory-test-*' | wc -l`
9+
// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l`
810
// RUN: [ $FILES -eq 0 ]
9-
// RUN: rm -f fdr-inmemory-test-*
11+
// RUN: rm -rf %t.dir
1012
//
1113
// REQUIRES: built-in-llvm-tree
1214

compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// RUN: %clangxx_xray -g -std=c++11 %s -o %t -fxray-modes=xray-fdr
2-
// RUN: rm -f fdr-inmemory-test-*
2+
// RUN: rm -rf %t.dir
3+
// RUN: mkdir -p %t.dir
4+
// RUN: cd %t.dir
35
// RUN: XRAY_OPTIONS="patch_premain=false xray_logfile_base=fdr-inmemory-test- \
46
// RUN: verbosity=1" \
57
// RUN: XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \
68
// RUN: %run %t 2>&1 | FileCheck %s
7-
// RUN: FILES=`find %T -name 'fdr-inmemory-test-*' | wc -l`
9+
// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l`
810
// RUN: [ $FILES -eq 0 ]
9-
// RUN: rm -f fdr-inmemory-test-*
11+
// RUN: rm -rf %t.dir
1012
//
1113
// REQUIRES: built-in-llvm-tree
1214

libc/src/__support/GPU/allocator.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,13 @@ struct GuardPtr {
460460
result->initialize(uniform);
461461
if (gpu::get_lane_id() == uint32_t(cpp::countr_zero(uniform)))
462462
finalize(result, cpp::popcount(uniform), count);
463+
count =
464+
gpu::shuffle(gpu::get_lane_mask(), cpp::countr_zero(uniform), count);
463465
}
464466

465467
if (!impl::is_sentinel(count))
466468
count = count - cpp::popcount(uniform) +
467-
impl::lane_count(uniform, gpu::get_lane_id()) + 1;
469+
impl::lane_count(uniform, gpu::get_lane_id());
468470

469471
return result;
470472
}
@@ -536,13 +538,13 @@ static Slab *find_slab(uint32_t chunk_size, uint64_t &uniform) {
536538
// If we find a slab with a matching chunk size then we store the result.
537539
// Otherwise, we need to free the claimed lock and continue. In the case
538540
// of out-of-memory we receive a sentinel value and return a failure.
539-
if (slab && reserved <= Slab::available_chunks(chunk_size) &&
541+
if (slab && reserved < Slab::available_chunks(chunk_size) &&
540542
slab->get_chunk_size() == chunk_size) {
541543
if (index != start)
542544
indices[chunk_id].store(index, cpp::MemoryOrder::RELAXED);
543545
uniform = uniform & gpu::get_lane_mask();
544546
return slab;
545-
} else if (slab && (reserved > Slab::available_chunks(chunk_size) ||
547+
} else if (slab && (reserved >= Slab::available_chunks(chunk_size) ||
546548
slab->get_chunk_size() != chunk_size)) {
547549
slots[index].unlock(gpu::get_lane_mask(),
548550
gpu::get_lane_mask() & uniform);

0 commit comments

Comments
 (0)