Skip to content

Commit 7792c2d

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:c49965b97e159b7ff92a5fca3e144b2d2574a84d into amd-gfx:75d03f4f8f7e
Local branch amd-gfx 75d03f4 Merged main:fc18b13492880ba8597333c6050a18ec6db0f831 into amd-gfx:599be57544a8 Remote branch main c49965b [mlgo] Fix post PR llvm#76919
2 parents 75d03f4 + c49965b commit 7792c2d

27 files changed

+718
-602
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ Bug Fixes in This Version
609609
- Clang will correctly evaluate ``noexcept`` expression for template functions
610610
of template classes. Fixes
611611
(`#68543 <https://github.com/llvm/llvm-project/issues/68543>`_,
612-
`#42496 <https://github.com/llvm/llvm-project/issues/42496>`_)
612+
`#42496 <https://github.com/llvm/llvm-project/issues/42496>`_,
613+
`#77071 <https://github.com/llvm/llvm-project/issues/77071>`_)
613614
- Fixed an issue when a shift count larger than ``__INT64_MAX__``, in a right
614615
shift operation, could result in missing warnings about
615616
``shift count >= width of type`` or internal compiler error.

clang/include/clang/AST/Type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,6 +4224,8 @@ class FunctionProtoType final
42244224
ExceptionSpecInfo() = default;
42254225

42264226
ExceptionSpecInfo(ExceptionSpecificationType EST) : Type(EST) {}
4227+
4228+
void instantiate();
42274229
};
42284230

42294231
/// Extra information about a function prototype. ExtProtoInfo is not

clang/lib/AST/Type.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,13 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
34143414
llvm_unreachable("Invalid calling convention.");
34153415
}
34163416

3417+
void FunctionProtoType::ExceptionSpecInfo::instantiate() {
3418+
assert(Type == EST_Uninstantiated);
3419+
NoexceptExpr =
3420+
cast<FunctionProtoType>(SourceTemplate->getType())->getNoexceptExpr();
3421+
Type = EST_DependentNoexcept;
3422+
}
3423+
34173424
FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
34183425
QualType canonical,
34193426
const ExtProtoInfo &epi)

clang/lib/Headers/llvm_libc_wrappers/stdio.h

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,41 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
10-
#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
11-
129
#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
1310
#error "This file is for GPU offloading compilation only"
1411
#endif
1512

1613
#include_next <stdio.h>
1714

15+
// In some old versions of glibc, other standard headers sometimes define
16+
// special macros (e.g., __need_FILE) before including stdio.h to cause stdio.h
17+
// to produce special definitions. Future includes of stdio.h when those
18+
// special macros are undefined are expected to produce the normal definitions
19+
// from stdio.h.
20+
//
21+
// We do not apply our include guard (__CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__)
22+
// unconditionally to the above include_next. Otherwise, after an occurrence of
23+
// the first glibc stdio.h use case described above, the include_next would be
24+
// skipped for remaining includes of stdio.h, leaving required symbols
25+
// undefined.
26+
//
27+
// We make the following assumptions to handle all use cases:
28+
//
29+
// 1. If the above include_next produces special glibc definitions, then (a) it
30+
// does not produce the normal definitions that we must intercept below, (b)
31+
// the current file was included from a glibc header that already defined
32+
// __GLIBC__ (usually by including glibc's <features.h>), and (c) the above
33+
// include_next does not define _STDIO_H. In that case, we skip the rest of
34+
// the current file and don't guard against future includes.
35+
// 2. If the above include_next produces the normal stdio.h definitions, then
36+
// either (a) __GLIBC__ is not defined because C headers are from some other
37+
// libc implementation or (b) the above include_next defines _STDIO_H to
38+
// prevent the above include_next from having any effect in the future.
39+
#if !defined(__GLIBC__) || defined(_STDIO_H)
40+
41+
#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
42+
#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
43+
1844
#if __has_include(<llvm-libc-decls/stdio.h>)
1945

2046
#if defined(__HIP__) || defined(__CUDA__)
@@ -50,3 +76,5 @@
5076
#endif
5177

5278
#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
79+
80+
#endif

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,6 +4737,7 @@ namespace {
47374737
QualType Replacement;
47384738
bool ReplacementIsPack;
47394739
bool UseTypeSugar;
4740+
using inherited = TreeTransform<SubstituteDeducedTypeTransform>;
47404741

47414742
public:
47424743
SubstituteDeducedTypeTransform(Sema &SemaRef, DependentAuto DA)
@@ -4797,6 +4798,16 @@ namespace {
47974798
// Lambdas never need to be transformed.
47984799
return E;
47994800
}
4801+
bool TransformExceptionSpec(SourceLocation Loc,
4802+
FunctionProtoType::ExceptionSpecInfo &ESI,
4803+
SmallVectorImpl<QualType> &Exceptions,
4804+
bool &Changed) {
4805+
if (ESI.Type == EST_Uninstantiated) {
4806+
ESI.instantiate();
4807+
Changed = true;
4808+
}
4809+
return inherited::TransformExceptionSpec(Loc, ESI, Exceptions, Changed);
4810+
}
48004811

48014812
QualType Apply(TypeLoc TL) {
48024813
// Create some scratch storage for the transformed type locations.

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,9 +1639,7 @@ bool TemplateInstantiator::TransformExceptionSpec(
16391639
SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI,
16401640
SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
16411641
if (ESI.Type == EST_Uninstantiated) {
1642-
ESI.NoexceptExpr = cast<FunctionProtoType>(ESI.SourceTemplate->getType())
1643-
->getNoexceptExpr();
1644-
ESI.Type = EST_DependentNoexcept;
1642+
ESI.instantiate();
16451643
Changed = true;
16461644
}
16471645
return inherited::TransformExceptionSpec(Loc, ESI, Exceptions, Changed);

clang/test/CodeGen/RISCV/riscv-abi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --filter "^define |^entry:" --version 2
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "^define |^entry:" --version 2
22
// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - \
33
// RUN: | FileCheck -check-prefixes=ILP32-ILP32F-ILP32D,ILP32-ILP32F,ILP32 %s
44
// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm %s -o - \

clang/test/CodeGen/isfpclass.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _Bool check_isfpclass_finite(float x) {
1515
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_finite_strict
1616
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
1717
// CHECK-NEXT: entry:
18-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR6:[0-9]+]]
18+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR5:[0-9]+]]
1919
// CHECK-NEXT: ret i1 [[TMP0]]
2020
//
2121
_Bool check_isfpclass_finite_strict(float x) {
@@ -24,7 +24,7 @@ _Bool check_isfpclass_finite_strict(float x) {
2424
}
2525

2626
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_nan_f32
27-
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
27+
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
2828
// CHECK-NEXT: entry:
2929
// CHECK-NEXT: [[TMP0:%.*]] = fcmp uno float [[X]], 0.000000e+00
3030
// CHECK-NEXT: ret i1 [[TMP0]]
@@ -36,7 +36,7 @@ _Bool check_isfpclass_nan_f32(float x) {
3636
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_nan_f32_strict
3737
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
3838
// CHECK-NEXT: entry:
39-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR6]]
39+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR5]]
4040
// CHECK-NEXT: ret i1 [[TMP0]]
4141
//
4242
_Bool check_isfpclass_nan_f32_strict(float x) {
@@ -57,7 +57,7 @@ _Bool check_isfpclass_snan_f64(double x) {
5757
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_snan_f64_strict
5858
// CHECK-SAME: (double noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
5959
// CHECK-NEXT: entry:
60-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f64(double [[X]], i32 1) #[[ATTR6]]
60+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f64(double [[X]], i32 1) #[[ATTR5]]
6161
// CHECK-NEXT: ret i1 [[TMP0]]
6262
//
6363
_Bool check_isfpclass_snan_f64_strict(double x) {
@@ -66,7 +66,7 @@ _Bool check_isfpclass_snan_f64_strict(double x) {
6666
}
6767

6868
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_zero_f16
69-
// CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3]] {
69+
// CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
7070
// CHECK-NEXT: entry:
7171
// CHECK-NEXT: [[TMP0:%.*]] = fcmp oeq half [[X]], 0xH0000
7272
// CHECK-NEXT: ret i1 [[TMP0]]
@@ -78,7 +78,7 @@ _Bool check_isfpclass_zero_f16(_Float16 x) {
7878
// CHECK-LABEL: define dso_local noundef i1 @check_isfpclass_zero_f16_strict
7979
// CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
8080
// CHECK-NEXT: entry:
81-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f16(half [[X]], i32 96) #[[ATTR6]]
81+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f16(half [[X]], i32 96) #[[ATTR5]]
8282
// CHECK-NEXT: ret i1 [[TMP0]]
8383
//
8484
_Bool check_isfpclass_zero_f16_strict(_Float16 x) {
@@ -89,7 +89,7 @@ _Bool check_isfpclass_zero_f16_strict(_Float16 x) {
8989
// CHECK-LABEL: define dso_local noundef i1 @check_isnan
9090
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
9191
// CHECK-NEXT: entry:
92-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR6]]
92+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR5]]
9393
// CHECK-NEXT: ret i1 [[TMP0]]
9494
//
9595
_Bool check_isnan(float x) {
@@ -100,7 +100,7 @@ _Bool check_isnan(float x) {
100100
// CHECK-LABEL: define dso_local noundef i1 @check_isinf
101101
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
102102
// CHECK-NEXT: entry:
103-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 516) #[[ATTR6]]
103+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 516) #[[ATTR5]]
104104
// CHECK-NEXT: ret i1 [[TMP0]]
105105
//
106106
_Bool check_isinf(float x) {
@@ -111,7 +111,7 @@ _Bool check_isinf(float x) {
111111
// CHECK-LABEL: define dso_local noundef i1 @check_isfinite
112112
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
113113
// CHECK-NEXT: entry:
114-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR6]]
114+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR5]]
115115
// CHECK-NEXT: ret i1 [[TMP0]]
116116
//
117117
_Bool check_isfinite(float x) {
@@ -122,7 +122,7 @@ _Bool check_isfinite(float x) {
122122
// CHECK-LABEL: define dso_local noundef i1 @check_isnormal
123123
// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
124124
// CHECK-NEXT: entry:
125-
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 264) #[[ATTR6]]
125+
// CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 264) #[[ATTR5]]
126126
// CHECK-NEXT: ret i1 [[TMP0]]
127127
//
128128
_Bool check_isnormal(float x) {
@@ -137,7 +137,7 @@ typedef int __attribute__((ext_vector_type(4))) int4;
137137
typedef long __attribute__((ext_vector_type(4))) long4;
138138

139139
// CHECK-LABEL: define dso_local noundef <4 x i32> @check_isfpclass_nan_v4f32
140-
// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3]] {
140+
// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
141141
// CHECK-NEXT: entry:
142142
// CHECK-NEXT: [[TMP0:%.*]] = fcmp uno <4 x float> [[X]], zeroinitializer
143143
// CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i1> [[TMP0]] to <4 x i32>
@@ -150,7 +150,7 @@ int4 check_isfpclass_nan_v4f32(float4 x) {
150150
// CHECK-LABEL: define dso_local noundef <4 x i32> @check_isfpclass_nan_strict_v4f32
151151
// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
152152
// CHECK-NEXT: entry:
153-
// CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x i1> @llvm.is.fpclass.v4f32(<4 x float> [[X]], i32 3) #[[ATTR6]]
153+
// CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x i1> @llvm.is.fpclass.v4f32(<4 x float> [[X]], i32 3) #[[ATTR5]]
154154
// CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i1> [[TMP0]] to <4 x i32>
155155
// CHECK-NEXT: ret <4 x i32> [[TMP1]]
156156
//
@@ -160,7 +160,7 @@ int4 check_isfpclass_nan_strict_v4f32(float4 x) {
160160
}
161161

162162
// CHECK-LABEL: define dso_local void @check_isfpclass_nan_v4f64
163-
// CHECK-SAME: (ptr noalias nocapture writeonly sret(<4 x i64>) align 16 [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[TMP0:%.*]]) local_unnamed_addr #[[ATTR4:[0-9]+]] {
163+
// CHECK-SAME: (ptr noalias nocapture writeonly sret(<4 x i64>) align 16 [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
164164
// CHECK-NEXT: entry:
165165
// CHECK-NEXT: [[X:%.*]] = load <4 x double>, ptr [[TMP0]], align 16, !tbaa [[TBAA2:![0-9]+]]
166166
// CHECK-NEXT: [[TMP1:%.*]] = fcmp uno <4 x double> [[X]], zeroinitializer

0 commit comments

Comments
 (0)