Skip to content

Commit 2949485

Browse files
Trim lit tests and format fixes
1 parent 7fd51cc commit 2949485

File tree

5 files changed

+9
-89
lines changed

5 files changed

+9
-89
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,44 +4046,29 @@ template <typename AttrT> static bool hasImplicitAttr(const ValueDecl *D) {
40464046
static bool shouldSkipAliasEmission(const CodeGenModule &CGM,
40474047
const ValueDecl *Global) {
40484048
const LangOptions &LangOpts = CGM.getLangOpts();
4049-
if (!(LangOpts.OpenMPIsTargetDevice || LangOpts.CUDA))
4049+
if (!LangOpts.OpenMPIsTargetDevice && !LangOpts.CUDA)
40504050
return false;
40514051

40524052
const auto *AA = Global->getAttr<AliasAttr>();
40534053
GlobalDecl AliaseeGD;
40544054

4055-
// Check if the aliasee exists.
4056-
if (!CGM.lookupRepresentativeDecl(AA->getAliasee(), AliaseeGD)) {
4057-
// If the aliasee is not found, skip the alias emission.
4058-
// This is not a hard error as this branch is executed for both the host
4059-
// and device, with no respect to where the aliasee is defined.
4060-
// For some OpenMP cases (functions) this will return true even if the
4061-
// aliasee is not on the device, which is handled by the case below
4055+
// Check if the aliasee exists, if the aliasee is not found, skip the alias
4056+
// emission. This is executed for both the host and device.
4057+
if (!CGM.lookupRepresentativeDecl(AA->getAliasee(), AliaseeGD))
40624058
return true;
4063-
}
40644059

40654060
const auto *AliaseeDecl = dyn_cast<ValueDecl>(AliaseeGD.getDecl());
4066-
if (LangOpts.OpenMPIsTargetDevice) {
4067-
if (!AliaseeDecl ||
4068-
!OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(AliaseeDecl))
4069-
// On OpenMP device, skip alias emission if the aliasee is not marked
4070-
// with declare target.
4071-
return true;
4072-
return false;
4073-
}
4061+
if (LangOpts.OpenMPIsTargetDevice)
4062+
return !AliaseeDecl ||
4063+
!OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(AliaseeDecl);
40744064

40754065
// CUDA / HIP
40764066
const bool HasDeviceAttr = Global->hasAttr<CUDADeviceAttr>();
40774067
const bool AliaseeHasDeviceAttr =
40784068
AliaseeDecl && AliaseeDecl->hasAttr<CUDADeviceAttr>();
40794069

4080-
if (LangOpts.CUDAIsDevice) {
4081-
if (!HasDeviceAttr || !AliaseeHasDeviceAttr)
4082-
// On device, skip alias emission if either the alias or the aliasee
4083-
// is not marked with __device__.
4084-
return true;
4085-
return false;
4086-
}
4070+
if (LangOpts.CUDAIsDevice)
4071+
return !HasDeviceAttr || !AliaseeHasDeviceAttr;
40874072

40884073
// CUDA / HIP Host
40894074
// we know that the aliasee exists from above, so we know to emit

clang/test/CodeGenCUDA/cuda_weak_alias.cu

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals all --version 6
2-
// REQUIRES: nvptx-registered-target
32
// RUN: %clang_cc1 -x cuda -triple x86_64-unknown-linux-gnu -aux-triple nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
43

54
extern "C" {
@@ -16,9 +15,3 @@ int __HostFunc(void) { return 42; }
1615
int HostFunc(void) __attribute__ ((weak, alias("__HostFunc")));
1716

1817
}
19-
//.
20-
// HOST: attributes #[[ATTR0]] = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
21-
//.
22-
// HOST: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
23-
// HOST: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
24-
//.

clang/test/CodeGenHIP/hip_weak_alias.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
extern "C" {
1111
//.
12-
// HOST: @__HostVar = global i32 1, align 4
13-
// HOST: @__hip_cuid_ = global i8 0
14-
// HOST: @llvm.compiler.used = appending global [1 x ptr] [ptr @__hip_cuid_], section "llvm.metadata"
1512
// HOST: @HostFunc = weak alias i32 (), ptr @__HostFunc
1613
// HOST: @HostFunc_ = alias i32 (), ptr @__HostFunc
1714
// HOST: @HostVar = weak alias i32, ptr @__HostVar
@@ -23,8 +20,6 @@ extern "C" {
2320
// HOST: @_Z4Fourv = weak alias i32 (), ptr @_Z6__Fourv
2421
// HOST: @_Z4Fourf = weak alias float (float), ptr @_Z6__Fourf
2522
//.
26-
// DEVICE: @__hip_cuid_ = addrspace(1) global i8 0
27-
// DEVICE: @llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr addrspacecast (ptr addrspace(1) @__hip_cuid_ to ptr)], section "llvm.metadata"
2823
// DEVICE: @One = weak alias i32 (), ptr @__One
2924
// DEVICE: @One_ = alias i32 (), ptr @__One
3025
// DEVICE: @Two = weak alias i32 (), ptr @__Two
@@ -128,17 +123,3 @@ __host__ __device__ int __Four(void) { return 2; }
128123
__host__ __device__ float __Four(float f) { return 2.0f * f; }
129124
__host__ __device__ int Four(void) __attribute__((weak, alias("_Z6__Fourv")));
130125
__host__ __device__ float Four(float f) __attribute__((weak, alias("_Z6__Fourf")));
131-
132-
//.
133-
// HOST: attributes #[[ATTR0]] = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
134-
//.
135-
// DEVICE: attributes #[[ATTR0]] = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
136-
//.
137-
// HOST: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
138-
// HOST: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
139-
//.
140-
// DEVICE: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 600}
141-
// DEVICE: [[META1:![0-9]+]] = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
142-
// DEVICE: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
143-
// DEVICE: [[META3:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
144-
//.

clang/test/OpenMP/amdgcn_weak_alias.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
// HOST: @Three_var = weak alias i32, ptr @__Three_var
2727
// HOST: @Three_var_ = alias i32, ptr @__Three_var
2828
//.
29-
// DEVICE: @__omp_rtl_debug_kind = weak_odr hidden addrspace(1) constant i32 0
30-
// DEVICE: @__omp_rtl_assume_teams_oversubscription = weak_odr hidden addrspace(1) constant i32 0
31-
// DEVICE: @__omp_rtl_assume_threads_oversubscription = weak_odr hidden addrspace(1) constant i32 0
32-
// DEVICE: @__omp_rtl_assume_no_thread_state = weak_odr hidden addrspace(1) constant i32 0
33-
// DEVICE: @__omp_rtl_assume_no_nested_parallelism = weak_odr hidden addrspace(1) constant i32 0
3429
// DEVICE: @__Two_var = addrspace(1) global i32 2, align 4
3530
// DEVICE: @__Three_var = addrspace(1) global i32 3, align 4
3631
// DEVICE: @Two = weak hidden alias i32 (), ptr @__Two
@@ -100,23 +95,9 @@ int Three_(void) __attribute__ ((alias("__Three")));
10095
extern int __attribute__((weak, alias("__Three_var"))) Three_var;
10196
extern int __attribute__((alias("__Three_var"))) Three_var_;
10297
//.
103-
// HOST: attributes #[[ATTR0]] = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
104-
//.
105-
// DEVICE: attributes #[[ATTR0]] = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
106-
//.
10798
// HOST: [[META0:![0-9]+]] = !{i32 1, !"__Two_var", i32 0, i32 0}
10899
// HOST: [[META1:![0-9]+]] = !{i32 1, !"__Three_var", i32 0, i32 1}
109-
// HOST: [[META2:![0-9]+]] = !{ptr @.offloading.entry_name}
110-
// HOST: [[META3:![0-9]+]] = !{ptr @.offloading.entry_name.1}
111-
// HOST: [[META4:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
112-
// HOST: [[META5:![0-9]+]] = !{i32 7, !"openmp", i32 51}
113-
// HOST: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
114100
//.
115101
// DEVICE: [[META0:![0-9]+]] = !{i32 1, !"__Two_var", i32 0, i32 0}
116102
// DEVICE: [[META1:![0-9]+]] = !{i32 1, !"__Three_var", i32 0, i32 1}
117-
// DEVICE: [[META2:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 600}
118-
// DEVICE: [[META3:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
119-
// DEVICE: [[META4:![0-9]+]] = !{i32 7, !"openmp", i32 51}
120-
// DEVICE: [[META5:![0-9]+]] = !{i32 7, !"openmp-device", i32 51}
121-
// DEVICE: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
122103
//.

clang/test/OpenMP/amdgcn_weak_alias.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
// HOST: @_Z4Fourv = weak alias i32 (), ptr @_Z6__Fourv
1818
// HOST: @_Z5Four_v = alias i32 (), ptr @_Z6__Fourv
1919
//.
20-
// DEVICE: @__omp_rtl_debug_kind = weak_odr hidden addrspace(1) constant i32 0
21-
// DEVICE: @__omp_rtl_assume_teams_oversubscription = weak_odr hidden addrspace(1) constant i32 0
22-
// DEVICE: @__omp_rtl_assume_threads_oversubscription = weak_odr hidden addrspace(1) constant i32 0
23-
// DEVICE: @__omp_rtl_assume_no_thread_state = weak_odr hidden addrspace(1) constant i32 0
24-
// DEVICE: @__omp_rtl_assume_no_nested_parallelism = weak_odr hidden addrspace(1) constant i32 0
2520
// DEVICE: @_Z3Twov = weak hidden alias i32 (), ptr @_Z5__Twov
2621
// DEVICE: @_Z3Twof = weak hidden alias float (float), ptr @_Z5__Twof
2722
// DEVICE: @_Z4Two_v = hidden alias i32 (), ptr @_Z5__Twov
@@ -118,18 +113,3 @@ int Three_(void) __attribute__((alias("_Z7__Threev")));
118113
constexpr int __Four(void) { return 4; }
119114
int Four(void) __attribute__((weak, alias("_Z6__Fourv")));
120115
int Four_(void) __attribute__((alias("_Z6__Fourv")));
121-
//.
122-
// HOST: attributes #[[ATTR0]] = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
123-
//.
124-
// DEVICE: attributes #[[ATTR0]] = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
125-
//.
126-
// HOST: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
127-
// HOST: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 51}
128-
// HOST: [[META2:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
129-
//.
130-
// DEVICE: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 600}
131-
// DEVICE: [[META1:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
132-
// DEVICE: [[META2:![0-9]+]] = !{i32 7, !"openmp", i32 51}
133-
// DEVICE: [[META3:![0-9]+]] = !{i32 7, !"openmp-device", i32 51}
134-
// DEVICE: [[META4:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
135-
//.

0 commit comments

Comments
 (0)