Skip to content

Commit d736180

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3483)
2 parents 5159322 + 636fe93 commit d736180

File tree

30 files changed

+541
-135
lines changed

30 files changed

+541
-135
lines changed

.ci/compute_projects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"clang": {"compiler-rt"},
8181
"clang-tools-extra": {"libc"},
8282
"libc": {"libc"},
83+
"compiler-rt": {"compiler-rt"},
8384
".ci": {"compiler-rt", "libc"},
8485
}
8586
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {

.ci/compute_projects_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,32 @@ def test_clang_windows(self):
126126
)
127127
self.assertEqual(env_variables["enable_cir"], "OFF")
128128

129+
def test_compiler_rt(self):
130+
env_variables = compute_projects.get_env_variables(
131+
["compiler-rt/lib/asan/asan_allocator.cpp"], "Linux"
132+
)
133+
self.assertEqual(
134+
env_variables["projects_to_build"],
135+
"clang;lld",
136+
)
137+
self.assertEqual(
138+
env_variables["project_check_targets"],
139+
"",
140+
)
141+
self.assertEqual(env_variables["runtimes_to_build"], "compiler-rt")
142+
self.assertEqual(
143+
env_variables["runtimes_check_targets"],
144+
"check-compiler-rt",
145+
)
146+
self.assertEqual(
147+
env_variables["runtimes_check_targets_needs_reconfig"],
148+
"",
149+
)
150+
self.assertEqual(
151+
env_variables["enable_cir"],
152+
"OFF",
153+
)
154+
129155
def test_cir(self):
130156
env_variables = compute_projects.get_env_variables(
131157
["clang/lib/CIR/CMakeLists.txt"], "Linux"

compiler-rt/lib/asan/asan_mapping.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,29 @@
8383
// || `[0x0000000000, 0x0d5554ffff]` || LowMem ||
8484
//
8585
// Default Linux/AArch64 (39-bit VMA) mapping:
86-
// || `[0x2000000000, 0x7fffffffff]` || highmem ||
87-
// || `[0x1400000000, 0x1fffffffff]` || highshadow ||
88-
// || `[0x1200000000, 0x13ffffffff]` || shadowgap ||
89-
// || `[0x1000000000, 0x11ffffffff]` || lowshadow ||
90-
// || `[0x0000000000, 0x0fffffffff]` || lowmem ||
86+
// TODO: this mapping is ok, but the allocator size is too large on non-Android
87+
// AArch64 platforms (see asan_allocator.h)
88+
// || `[0x2000000000, 0x7fffffffff]` || highmem || 384GB
89+
// || `[0x1400000000, 0x1fffffffff]` || highshadow || 48GB
90+
// || `[0x1200000000, 0x13ffffffff]` || shadowgap || 8GB
91+
// || `[0x1000000000, 0x11ffffffff]` || lowshadow || 8GB
92+
// || `[0x0000000000, 0x0fffffffff]` || lowmem || 64GB
9193
//
9294
// Default Linux/AArch64 (42-bit VMA) mapping:
93-
// || `[0x10000000000, 0x3ffffffffff]` || highmem ||
94-
// || `[0x0a000000000, 0x0ffffffffff]` || highshadow ||
95-
// || `[0x09000000000, 0x09fffffffff]` || shadowgap ||
96-
// || `[0x08000000000, 0x08fffffffff]` || lowshadow ||
97-
// || `[0x00000000000, 0x07fffffffff]` || lowmem ||
95+
// TODO: this mapping is ok, but the allocator size is too large on non-Android
96+
// AArch64 platforms (see asan_allocator.h)
97+
// || `[0x09000000000, 0x03ffffffffff]` || highmem || 3520GB
98+
// || `[0x02200000000, 0x008fffffffff]` || highshadow || 440GB
99+
// || `[0x01200000000, 0x0021ffffffff]` || shadowgap || 64GB
100+
// || `[0x01000000000, 0x0011ffffffff]` || lowshadow || 8GB
101+
// || `[0x00000000000, 0x000fffffffff]` || lowmem || 64GB
102+
//
103+
// Default Linux/AArch64 (48-bit VMA) mapping:
104+
// || `[0x201000000000, 0xffffffffffff]` || HighMem || 229312GB
105+
// || `[0x041200000000, 0x200fffffffff]` || HighShadow || 28664GB
106+
// || `[0x001200000000, 0x0411ffffffff]` || ShadowGap || 4096GB
107+
// || `[0x001000000000, 0x0011ffffffff]` || LowShadow || 8GB
108+
// || `[0x000000000000, 0x000fffffffff]` || LowMem || 64GB
98109
//
99110
// Default Linux/S390 mapping:
100111
// || `[0x30000000, 0x7fffffff]` || HighMem ||

compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
9797

9898
#if defined(__ANDROID__)
9999
extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
100-
static void abort_with_message(const char *kind, uintptr_t caller) {
100+
static void abort_with_message(const char *kind, uintptr_t caller,
101+
const uintptr_t *address) {
101102
char msg_buf[128];
102-
format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
103+
format_msg(kind, caller, address, msg_buf, msg_buf + sizeof(msg_buf));
103104
if (&android_set_abort_message)
104105
android_set_abort_message(msg_buf);
105106
abort();
106107
}
107108
#else
108-
static void abort_with_message(const char *kind, uintptr_t caller) { abort(); }
109+
static void abort_with_message(const char *kind, uintptr_t caller,
110+
const uintptr_t *address) {
111+
abort();
112+
}
109113
#endif
110114

111115
#if SANITIZER_DEBUG
@@ -132,7 +136,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
132136
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
133137
uintptr_t caller = GET_CALLER_PC(); \
134138
__ubsan_report_error_fatal(kind, caller, nullptr); \
135-
abort_with_message(kind, caller); \
139+
abort_with_message(kind, caller, nullptr); \
136140
}
137141

138142
#define HANDLER(name, kind) \
@@ -149,7 +153,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
149153
const uintptr_t address) { \
150154
uintptr_t caller = GET_CALLER_PC(); \
151155
__ubsan_report_error_fatal(kind, caller, &address); \
152-
abort_with_message(kind, caller); \
156+
abort_with_message(kind, caller, &address); \
153157
}
154158

155159
// A version of a handler that takes a pointer to a value.

flang/include/flang/Support/Fortran.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ static constexpr IgnoreTKRSet ignoreTKRAll{IgnoreTKR::Type, IgnoreTKR::Kind,
9595
std::string AsFortran(IgnoreTKRSet);
9696

9797
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr>,
98-
std::optional<CUDADataAttr>, IgnoreTKRSet, std::optional<std::string> *,
99-
bool allowUnifiedMatchingRule, bool isHostDeviceProcedure,
98+
std::optional<CUDADataAttr>, IgnoreTKRSet, bool allowUnifiedMatchingRule,
99+
bool isHostDeviceProcedure,
100100
const LanguageFeatureControl *features = nullptr);
101101

102102
static constexpr char blankCommonObjectName[] = "__BLNK__";

flang/lib/Evaluate/characteristics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ bool DummyDataObject::IsCompatibleWith(const DummyDataObject &actual,
400400
}
401401
if (!attrs.test(Attr::Value) &&
402402
!common::AreCompatibleCUDADataAttrs(cudaDataAttr, actual.cudaDataAttr,
403-
ignoreTKR, warning,
403+
ignoreTKR,
404404
/*allowUnifiedMatchingRule=*/false,
405405
/*=isHostDeviceProcedure*/ false)) {
406406
if (whyNot) {
@@ -1816,7 +1816,7 @@ bool DistinguishUtils::Distinguishable(
18161816
x.intent != common::Intent::In) {
18171817
return true;
18181818
} else if (!common::AreCompatibleCUDADataAttrs(x.cudaDataAttr, y.cudaDataAttr,
1819-
x.ignoreTKR | y.ignoreTKR, nullptr,
1819+
x.ignoreTKR | y.ignoreTKR,
18201820
/*allowUnifiedMatchingRule=*/false,
18211821
/*=isHostDeviceProcedure*/ false)) {
18221822
return true;

flang/lib/Lower/Bridge.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4902,7 +4902,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
49024902

49034903
// device = device
49044904
if (lhsIsDevice && rhsIsDevice) {
4905-
assert(rhs.isVariable() && "CUDA Fortran assignment rhs is not legal");
49064905
auto transferKindAttr = cuf::DataTransferKindAttr::get(
49074906
builder.getContext(), cuf::DataTransferKind::DeviceDevice);
49084907
cuf::DataTransferOp::create(builder, loc, rhsVal, lhsVal, shape,

flang/lib/Semantics/check-call.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,11 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
10581058
dummyName);
10591059
}
10601060
}
1061-
std::optional<std::string> warning;
10621061
bool isHostDeviceProc{procedure.cudaSubprogramAttrs &&
10631062
*procedure.cudaSubprogramAttrs ==
10641063
common::CUDASubprogramAttrs::HostDevice};
10651064
if (!common::AreCompatibleCUDADataAttrs(dummyDataAttr, actualDataAttr,
1066-
dummy.ignoreTKR, &warning, /*allowUnifiedMatchingRule=*/true,
1065+
dummy.ignoreTKR, /*allowUnifiedMatchingRule=*/true,
10671066
isHostDeviceProc, &context.languageFeatures())) {
10681067
auto toStr{[](std::optional<common::CUDADataAttr> x) {
10691068
return x ? "ATTRIBUTES("s +
@@ -1074,10 +1073,6 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
10741073
"%s has %s but its associated actual argument has %s"_err_en_US,
10751074
dummyName, toStr(dummyDataAttr), toStr(actualDataAttr));
10761075
}
1077-
if (warning && context.ShouldWarn(common::UsageWarning::CUDAUsage)) {
1078-
messages.Say(common::UsageWarning::CUDAUsage, "%s"_warn_en_US,
1079-
std::move(*warning));
1080-
}
10811076
}
10821077

10831078
// Warning for breaking F'2023 change with character allocatables

flang/lib/Support/Fortran.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ std::string AsFortran(IgnoreTKRSet tkr) {
103103
/// dummy argument attribute while `y` represents the actual argument attribute.
104104
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
105105
std::optional<CUDADataAttr> y, IgnoreTKRSet ignoreTKR,
106-
std::optional<std::string> *warning, bool allowUnifiedMatchingRule,
107-
bool isHostDeviceProcedure, const LanguageFeatureControl *features) {
106+
bool allowUnifiedMatchingRule, bool isHostDeviceProcedure,
107+
const LanguageFeatureControl *features) {
108108
bool isCudaManaged{features
109109
? features->IsEnabled(common::LanguageFeature::CudaManaged)
110110
: false};
@@ -145,9 +145,6 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
145145
*y == CUDADataAttr::Shared ||
146146
*y == CUDADataAttr::Constant)) ||
147147
(!y && (isCudaUnified || isCudaManaged))) {
148-
if (y && *y == CUDADataAttr::Shared && warning) {
149-
*warning = "SHARED attribute ignored"s;
150-
}
151148
return true;
152149
}
153150
} else if (*x == CUDADataAttr::Managed) {

flang/test/Lower/CUDA/cuda-data-transfer.cuf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,15 @@ subroutine sub23(n)
444444
end subroutine
445445

446446
! CHECK-LABEL: func.func @_QPsub23
447+
448+
subroutine sub24()
449+
real, managed :: m
450+
real, device :: d(4)
451+
m = d(1)
452+
end
453+
454+
! CHECK-LABEL: func.func @_QPsub24()
455+
! CHECK: %[[D:.*]]:2 = hlfir.declare %1(%2) {data_attr = #cuf.cuda<device>, uniq_name = "_QFsub24Ed"} : (!fir.ref<!fir.array<4xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<4xf32>>, !fir.ref<!fir.array<4xf32>>)
456+
! CHECK: %[[M:.*]]:2 = hlfir.declare %4 {data_attr = #cuf.cuda<managed>, uniq_name = "_QFsub24Em"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
457+
! CHECK: %[[D1:.*]] = hlfir.designate %[[D]]#0 (%c1{{.*}}) : (!fir.ref<!fir.array<4xf32>>, index) -> !fir.ref<f32>
458+
! CHECK: cuf.data_transfer %[[D1]] to %[[M]]#0 {transfer_kind = #cuf.cuda_transfer<device_device>} : !fir.ref<f32>, !fir.ref<f32>

0 commit comments

Comments
 (0)