Skip to content

Commit 5a3f4e4

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.7 [skip ci]
2 parents 0d75dbd + 764acd8 commit 5a3f4e4

32 files changed

+538
-566
lines changed

clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,11 @@ static auto isNotOkStatusCall() {
170170

171171
static auto isPointerComparisonOperatorCall(std::string operator_name) {
172172
using namespace ::clang::ast_matchers; // NOLINT: Too many names
173-
return binaryOperator(
174-
hasOperatorName(operator_name),
175-
hasLHS(
176-
anyOf(hasType(hasCanonicalType(pointerType(pointee(statusOrType())))),
177-
hasType(hasCanonicalType(pointerType(pointee(statusType())))))),
178-
hasRHS(hasType(hasCanonicalType(
179-
pointerType(pointee(anyOf(statusOrType(), statusOrType())))))));
173+
return binaryOperator(hasOperatorName(operator_name),
174+
hasLHS(hasType(hasCanonicalType(pointerType(
175+
pointee(anyOf(statusOrType(), statusType())))))),
176+
hasRHS(hasType(hasCanonicalType(pointerType(
177+
pointee(anyOf(statusOrType(), statusType())))))));
180178
}
181179

182180
static auto

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 137 additions & 142 deletions
Large diffs are not rendered by default.

clang/lib/Serialization/ASTReader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5811,7 +5811,13 @@ bool ASTReader::readASTFileControlBlock(
58115811

58125812
// FIXME: This allows use of the VFS; we do not allow use of the
58135813
// VFS when actually loading a module.
5814-
auto BufferOrErr = FileMgr.getBufferForFile(Filename);
5814+
auto Entry =
5815+
Filename == "-" ? FileMgr.getSTDIN() : FileMgr.getFileRef(Filename);
5816+
if (!Entry) {
5817+
llvm::consumeError(Entry.takeError());
5818+
return true;
5819+
}
5820+
auto BufferOrErr = FileMgr.getBufferForFile(*Entry);
58155821
if (!BufferOrErr)
58165822
return true;
58175823
OwnedBuffer = std::move(*BufferOrErr);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
2+
3+
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
4+
// RUN: | FileCheck %s --check-prefixes=CLEAN-O1
5+
6+
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
7+
// RUN: -fsanitize=signed-integer-overflow \
8+
// RUN: -fsanitize-skip-hot-cutoff=signed-integer-overflow=1.0 \
9+
// RUN: -fallow-runtime-check-skip-hot-cutoff=1.0 \
10+
// RUN: | FileCheck %s --check-prefixes=UBSAN-O1
11+
12+
// This test shows that -fsanitize-skip-hot-cutoff=...=1.0 plus
13+
// -fallow-runtime-check-skip-hot-cutoff=1.0 does not perfectly undo the
14+
// effects of -fsanitize.
15+
16+
// CLEAN-O1-LABEL: define dso_local i32 @overflow(
17+
// CLEAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
18+
// CLEAN-O1-NEXT: [[ENTRY:.*:]]
19+
// CLEAN-O1-NEXT: [[ADD:%.*]] = add nsw i32 [[Y]], [[X]]
20+
// CLEAN-O1-NEXT: ret i32 [[ADD]]
21+
//
22+
// UBSAN-O1-LABEL: define dso_local noundef i32 @overflow(
23+
// UBSAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
24+
// UBSAN-O1-NEXT: [[ENTRY:.*:]]
25+
// UBSAN-O1-NEXT: [[TMP0:%.*]] = add i32 [[X]], [[Y]]
26+
// UBSAN-O1-NEXT: ret i32 [[TMP0]]
27+
//
28+
int overflow(int x, int y) {
29+
return x + y;
30+
}

compiler-rt/lib/builtins/gcc_personality_v0.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
3030
_Unwind_Personality_Fn);
3131
#endif
3232

33+
#ifndef __has_feature
34+
#define __has_feature(__feature) 0
35+
#endif
36+
3337
#if __has_feature(ptrauth_calls)
3438
#include <ptrauth.h>
3539

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,18 @@ static constexpr IntrinsicHandler handlers[]{
989989
{"mask", asBox, handleDynamicOptional}}},
990990
/*isElemental=*/false},
991991
{"syncthreads", &I::genSyncThreads, {}, /*isElemental=*/false},
992-
{"syncthreads_and", &I::genSyncThreadsAnd, {}, /*isElemental=*/false},
993-
{"syncthreads_count", &I::genSyncThreadsCount, {}, /*isElemental=*/false},
994-
{"syncthreads_or", &I::genSyncThreadsOr, {}, /*isElemental=*/false},
992+
{"syncthreads_and_i4", &I::genSyncThreadsAnd, {}, /*isElemental=*/false},
993+
{"syncthreads_and_l4", &I::genSyncThreadsAnd, {}, /*isElemental=*/false},
994+
{"syncthreads_count_i4",
995+
&I::genSyncThreadsCount,
996+
{},
997+
/*isElemental=*/false},
998+
{"syncthreads_count_l4",
999+
&I::genSyncThreadsCount,
1000+
{},
1001+
/*isElemental=*/false},
1002+
{"syncthreads_or_i4", &I::genSyncThreadsOr, {}, /*isElemental=*/false},
1003+
{"syncthreads_or_l4", &I::genSyncThreadsOr, {}, /*isElemental=*/false},
9951004
{"syncwarp", &I::genSyncWarp, {}, /*isElemental=*/false},
9961005
{"system",
9971006
&I::genSystem,

flang/module/cudadevice.f90

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,32 @@ module cudadevice
2121
procedure :: syncthreads
2222
end interface
2323

24-
interface
25-
attributes(device) integer function syncthreads_and(value)
26-
integer, value :: value
24+
interface syncthreads_and
25+
attributes(device) integer function syncthreads_and_i4(value)
26+
integer(4), value :: value
2727
end function
28-
end interface
28+
attributes(device) integer function syncthreads_and_l4(value)
29+
logical(4), value :: value
30+
end function
31+
end interface syncthreads_and
2932

30-
interface
31-
attributes(device) integer function syncthreads_count(value)
32-
integer, value :: value
33+
interface syncthreads_count
34+
attributes(device) integer function syncthreads_count_i4(value)
35+
integer(4), value :: value
3336
end function
34-
end interface
37+
attributes(device) integer function syncthreads_count_l4(value)
38+
logical(4), value :: value
39+
end function
40+
end interface syncthreads_count
3541

36-
interface
37-
attributes(device) integer function syncthreads_or(value)
38-
integer, value :: value
42+
interface syncthreads_or
43+
attributes(device) integer function syncthreads_or_i4(value)
44+
integer(4), value :: value
3945
end function
40-
end interface
46+
attributes(device) integer function syncthreads_or_l4(value)
47+
logical(4), value :: value
48+
end function
49+
end interface syncthreads_or
4150

4251
interface
4352
attributes(device) subroutine syncwarp(mask)

flang/test/Lower/CUDA/cuda-device-proc.cuf

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ attributes(global) subroutine devsub()
1212
integer(8) :: al
1313
integer(8) :: time
1414
integer :: smalltime
15-
integer(4) :: res
15+
integer(4) :: res, offset
1616
integer(8) :: resl
1717

18+
integer :: tid
19+
tid = threadIdx%x
20+
1821
call syncthreads()
1922
call syncwarp(1)
2023
call threadfence()
2124
call threadfence_block()
2225
call threadfence_system()
2326
ret = syncthreads_and(1)
27+
res = syncthreads_and(tid > offset)
2428
ret = syncthreads_count(1)
29+
ret = syncthreads_count(tid > offset)
2530
ret = syncthreads_or(1)
31+
ret = syncthreads_or(tid > offset)
2632

2733
ai = atomicadd(ai, 1_4)
2834
al = atomicadd(al, 1_8)
@@ -100,9 +106,21 @@ end
100106
! CHECK: fir.call @llvm.nvvm.membar.gl() fastmath<contract> : () -> ()
101107
! CHECK: fir.call @llvm.nvvm.membar.cta() fastmath<contract> : () -> ()
102108
! CHECK: fir.call @llvm.nvvm.membar.sys() fastmath<contract> : () -> ()
103-
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.and(%c1_i32_0) fastmath<contract> : (i32) -> i32
104-
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.popc(%c1_i32_1) fastmath<contract> : (i32) -> i32
105-
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.or(%c1_i32_2) fastmath<contract> : (i32) -> i32
109+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.and(%c1{{.*}}) fastmath<contract> : (i32) -> i32
110+
! CHECK: %[[A:.*]] = fir.load %{{.*}} : !fir.ref<i32>
111+
! CHECK: %[[B:.*]] = fir.load %{{.*}} : !fir.ref<i32>
112+
! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[A]], %[[B]] : i32
113+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.and(%[[CMP]])
114+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.popc(%c1{{.*}}) fastmath<contract> : (i32) -> i32
115+
! CHECK: %[[A:.*]] = fir.load %{{.*}} : !fir.ref<i32>
116+
! CHECK: %[[B:.*]] = fir.load %{{.*}} : !fir.ref<i32>
117+
! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[A]], %[[B]] : i32
118+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.popc(%[[CMP]]) fastmath<contract> : (i1) -> i32
119+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.or(%c1{{.*}}) fastmath<contract> : (i32) -> i32
120+
! CHECK: %[[A:.*]] = fir.load %{{.*}} : !fir.ref<i32>
121+
! CHECK: %[[B:.*]] = fir.load %{{.*}} : !fir.ref<i32>
122+
! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[A]], %[[B]] : i32
123+
! CHECK: %{{.*}} = fir.call @llvm.nvvm.barrier0.or(%[[CMP]]) fastmath<contract> : (i1) -> i32
106124
! CHECK: %{{.*}} = llvm.atomicrmw add %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, i32
107125
! CHECK: %{{.*}} = llvm.atomicrmw add %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, i64
108126
! CHECK: %{{.*}} = llvm.atomicrmw fadd %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, f32

libunwind/include/__libunwind_config.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@
212212
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
213213
#endif // _LIBUNWIND_IS_NATIVE_ONLY
214214

215-
#if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
216-
# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
217-
#elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
218-
# error "Either both or none of ptrauth_calls and ptrauth_returns "\
219-
"is allowed to be enabled"
215+
#if defined(__has_feature)
216+
# if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
217+
# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
218+
# elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
219+
# error "Either both or none of ptrauth_calls and ptrauth_returns "\
220+
"is allowed to be enabled"
221+
# endif
220222
#endif
221223

222224
#endif // ____LIBUNWIND_CONFIG_H__

libunwind/src/UnwindRegistersRestore.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ Lnovec:
634634

635635
#elif defined(__aarch64__)
636636

637+
#ifndef __has_feature
638+
#define __has_feature(__feature) 0
639+
#endif
640+
637641
#if defined(__ARM_FEATURE_GCS_DEFAULT)
638642
.arch_extension gcs
639643
#endif

0 commit comments

Comments
 (0)