Skip to content

Commit e57eb67

Browse files
authored
merge main into amd-staging (llvm#785)
2 parents 29cbf9c + ff75f37 commit e57eb67

File tree

36 files changed

+3623
-290
lines changed

36 files changed

+3623
-290
lines changed

.github/workflows/premerge.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ concurrency:
2525

2626
jobs:
2727
premerge-checks-linux:
28+
name: Linux Premerge Checks (Test Only - Please Ignore Results)
2829
if: >-
2930
github.repository_owner == 'llvm' &&
3031
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -83,6 +84,7 @@ jobs:
8384
./.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"
8485
8586
premerge-checks-windows:
87+
name: Windows Premerge Checks (Test Only - Please Ignore Results)
8688
if: >-
8789
github.repository_owner == 'llvm' &&
8890
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -143,6 +145,7 @@ jobs:
143145
bash .ci/monolithic-windows.sh "${{ steps.vars.outputs.windows-projects }}" "${{ steps.vars.outputs.windows-check-targets }}"
144146
145147
premerge-check-macos:
148+
name: MacOS Premerge Checks
146149
runs-on: macos-14
147150
if: >-
148151
github.repository_owner == 'llvm' &&

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,18 +832,15 @@ let Features = "rdseed", Attributes = [NoThrow] in {
832832
def rdseed32_step : X86Builtin<"unsigned int(unsigned int *)">;
833833
}
834834

835-
let Features = "lzcnt", Attributes = [NoThrow, Const, Constexpr] in {
836-
def lzcnt_u16 : X86Builtin<"unsigned short(unsigned short)">;
837-
def lzcnt_u32 : X86Builtin<"unsigned int(unsigned int)">;
838-
}
839-
840835
let Features = "bmi", Attributes = [NoThrow, Const, Constexpr] in {
841836
def bextr_u32 : X86Builtin<"unsigned int(unsigned int, unsigned int)">;
842837
}
843838

844839
let Attributes = [NoThrow, Const, Constexpr] in {
845840
def tzcnt_u16 : X86Builtin<"unsigned short(unsigned short)">;
846841
def tzcnt_u32 : X86Builtin<"unsigned int(unsigned int)">;
842+
def lzcnt_u16 : X86Builtin<"unsigned short(unsigned short)">;
843+
def lzcnt_u32 : X86Builtin<"unsigned int(unsigned int)">;
847844
}
848845

849846
let Features = "bmi2", Attributes = [NoThrow, Const, Constexpr] in {

clang/include/clang/Basic/BuiltinsX86_64.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,13 @@ let Features = "rdseed", Attributes = [NoThrow] in {
126126
def rdseed64_step : X86Builtin<"unsigned int(unsigned long long int *)">;
127127
}
128128

129-
let Features = "lzcnt", Attributes = [NoThrow, Const, Constexpr] in {
130-
def lzcnt_u64 : X86Builtin<"unsigned long long int(unsigned long long int)">;
131-
}
132-
133129
let Features = "bmi", Attributes = [NoThrow, Const, Constexpr] in {
134130
def bextr_u64 : X86Builtin<"unsigned long long int(unsigned long long int, unsigned long long int)">;
135131
}
136132

137133
let Attributes = [NoThrow, Const, Constexpr] in {
138134
def tzcnt_u64 : X86Builtin<"unsigned long long int(unsigned long long int)">;
135+
def lzcnt_u64 : X86Builtin<"unsigned long long int(unsigned long long int)">;
139136
}
140137

141138
let Features = "bmi2", Attributes = [NoThrow, Const, Constexpr] in {

clang/lib/Headers/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,25 @@ set(riscv_generated_files)
399399

400400
function(copy_header_to_output_dir src_dir file)
401401
set(src ${src_dir}/${file})
402-
set(dst ${output_dir}/${file})
403-
add_custom_command(OUTPUT ${dst}
404-
DEPENDS ${src}
405-
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
406-
COMMENT "Copying clang's ${file}...")
407-
list(APPEND out_files ${dst})
402+
if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
403+
set(dst ${output_dir}/${file})
404+
add_custom_command(OUTPUT ${dst}
405+
DEPENDS ${src}
406+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
407+
COMMENT "Copying clang's ${file}...")
408+
list(APPEND out_files ${dst})
409+
else()
410+
foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
411+
# Replace the special string with a per config directory.
412+
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} per_conf_output_dir ${output_dir})
413+
set(dst ${per_conf_output_dir}/${file})
414+
add_custom_command(OUTPUT ${dst}
415+
DEPENDS ${src}
416+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
417+
COMMENT "Copying clang's ${file}...")
418+
list(APPEND out_files ${dst})
419+
endforeach()
420+
endif()
408421
set(out_files ${out_files} PARENT_SCOPE)
409422
endfunction(copy_header_to_output_dir)
410423

clang/lib/Headers/lzcntintrin.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
#ifndef __LZCNTINTRIN_H
1515
#define __LZCNTINTRIN_H
1616

17-
/* Define the default attributes for the functions in this file. */
17+
/* Define the default attributes for the functions in this file.
18+
Allow using the lzcnt intrinsics even for non-LZCNT targets. Since the LZCNT
19+
intrinsics are mapped to llvm.ctlz.*, false, which can be lowered to BSR on
20+
non-LZCNT targets with zero-value input handled correctly. */
1821
#if defined(__cplusplus) && (__cplusplus >= 201103L)
1922
#define __DEFAULT_FN_ATTRS \
20-
__attribute__((__always_inline__, __nodebug__, __target__("lzcnt"))) constexpr
23+
__attribute__((__always_inline__, __nodebug__)) constexpr
2124
#else
22-
#define __DEFAULT_FN_ATTRS \
23-
__attribute__((__always_inline__, __nodebug__, __target__("lzcnt")))
25+
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
2426
#endif
2527

2628
#ifndef _MSC_VER

clang/test/CodeGen/X86/lzcnt-builtins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +lzcnt -emit-llvm -o - | FileCheck %s
2-
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +lzcnt -emit-llvm -o - | FileCheck %s
1+
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
2+
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
33

44

55
#include <immintrin.h>
@@ -56,4 +56,4 @@ char lzcntu32_2[_lzcnt_u32(0x00000010) == 27 ? 1 : -1];
5656
char lzcntu64_0[_lzcnt_u64(0x0000000000000000ULL) == 64 ? 1 : -1];
5757
char lzcntu64_1[_lzcnt_u64(0x8000000000000000ULL) == 0 ? 1 : -1];
5858
char lzcntu64_2[_lzcnt_u64(0x0000000100000000ULL) == 31 ? 1 : -1];
59-
#endif
59+
#endif

libc/src/stdio/scanf_core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ add_header_library(
5454
libc.src.__support.CPP.string_view
5555
)
5656

57-
if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD)
57+
if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD AND
58+
(NOT LIBC_TARGET_OS_IS_GPU))
5859
# Not all platforms have a file implementation. If file is unvailable, and a
5960
# full build is requested, then we must skip all file based scanf sections.
6061
return()

libc/test/src/stdio/scanf_core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ add_libc_unittest(
1818
libc.src.__support.arg_list
1919
)
2020

21-
if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD)
21+
if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD AND
22+
(NOT LIBC_TARGET_OS_IS_GPU))
2223
# Not all platforms have a file implementation. If file is unvailable, and a
2324
# full build is requested, then we must skip all file based scanf sections.
2425
return()

libcxx/cmake/caches/AMDGPU.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
33
set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
44
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
5-
set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
5+
set(LIBCXX_ENABLE_LOCALIZATION ON CACHE BOOL "")
66
set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
77
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
88
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")

libcxx/cmake/caches/NVPTX.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
33
set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
44
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
5-
set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
5+
set(LIBCXX_ENABLE_LOCALIZATION ON CACHE BOOL "")
66
set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
77
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
88
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")

0 commit comments

Comments
 (0)