Skip to content

Commit 858523c

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3497)
2 parents 2ee7acd + d3546a9 commit 858523c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2047
-1346
lines changed

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,6 @@ class DataAggregator : public DataReader {
502502
/// entries).
503503
void imputeFallThroughs();
504504

505-
/// Register profiled functions for lite mode.
506-
void registerProfiledFunctions();
507-
508505
/// Debugging dump methods
509506
void dump() const;
510507
void dump(const PerfBranchSample &Sample) const;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -581,26 +581,6 @@ void DataAggregator::imputeFallThroughs() {
581581
outs() << "BOLT-INFO: imputed " << InferredTraces << " traces\n";
582582
}
583583

584-
void DataAggregator::registerProfiledFunctions() {
585-
DenseSet<uint64_t> Addrs;
586-
for (const auto &Trace : llvm::make_first_range(Traces)) {
587-
if (Trace.Branch != Trace::FT_ONLY &&
588-
Trace.Branch != Trace::FT_EXTERNAL_ORIGIN)
589-
Addrs.insert(Trace.Branch);
590-
Addrs.insert(Trace.From);
591-
}
592-
593-
for (const auto [PC, _] : BasicSamples)
594-
Addrs.insert(PC);
595-
596-
for (const PerfMemSample &MemSample : MemSamples)
597-
Addrs.insert(MemSample.PC);
598-
599-
for (const uint64_t Addr : Addrs)
600-
if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr))
601-
Func->setHasProfileAvailable();
602-
}
603-
604584
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
605585
this->BC = &BC;
606586

@@ -623,7 +603,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
623603
exit(0);
624604
}
625605

626-
registerProfiledFunctions();
627606
return Error::success();
628607
}
629608

@@ -1368,6 +1347,10 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
13681347
}
13691348

13701349
const uint64_t FromOffset = Addr[0]->Offset;
1350+
BinaryFunction *FromFunc = getBinaryFunctionContainingAddress(FromOffset);
1351+
if (FromFunc)
1352+
FromFunc->setHasProfileAvailable();
1353+
13711354
int64_t Count = Counters[0];
13721355
int64_t Mispreds = Counters[1];
13731356

@@ -1378,6 +1361,11 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
13781361
return std::error_code();
13791362
}
13801363

1364+
const uint64_t ToOffset = Addr[1]->Offset;
1365+
BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(ToOffset);
1366+
if (ToFunc)
1367+
ToFunc->setHasProfileAvailable();
1368+
13811369
/// For fall-through types, adjust locations to match Trace container.
13821370
if (Type == FT || Type == FT_EXTERNAL_ORIGIN || Type == FT_EXTERNAL_RETURN) {
13831371
Addr[2] = Location(Addr[1]->Offset); // Trace To
@@ -1625,6 +1613,9 @@ std::error_code DataAggregator::parseBranchEvents() {
16251613
Traces.reserve(TraceMap.size());
16261614
for (const auto &[Trace, Info] : TraceMap) {
16271615
Traces.emplace_back(Trace, Info);
1616+
for (const uint64_t Addr : {Trace.Branch, Trace.From})
1617+
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr))
1618+
BF->setHasProfileAvailable();
16281619
}
16291620
clear(TraceMap);
16301621

@@ -1685,6 +1676,9 @@ std::error_code DataAggregator::parseBasicEvents() {
16851676
continue;
16861677
++NumTotalSamples;
16871678

1679+
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Sample->PC))
1680+
BF->setHasProfileAvailable();
1681+
16881682
++BasicSamples[Sample->PC];
16891683
EventNames.insert(Sample->EventName);
16901684
}
@@ -1722,6 +1716,9 @@ std::error_code DataAggregator::parseMemEvents() {
17221716
if (std::error_code EC = Sample.getError())
17231717
return EC;
17241718

1719+
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Sample->PC))
1720+
BF->setHasProfileAvailable();
1721+
17251722
MemSamples.emplace_back(std::move(Sample.get()));
17261723
}
17271724

flang/lib/Evaluate/tools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ struct CollectCudaSymbolsHelper : public SetTraverse<CollectCudaSymbolsHelper,
11291129
CollectCudaSymbolsHelper() : Base{*this} {}
11301130
using Base::operator();
11311131
semantics::UnorderedSymbolSet operator()(const Symbol &symbol) const {
1132-
return {symbol};
1132+
return {symbol.GetUltimate()};
11331133
}
11341134
// Overload some of the operator() to filter out the symbols that are not
11351135
// of interest for CUDA data transfer logic.

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module mod1
1313

1414
integer, device, dimension(11:20) :: cdev
1515

16+
real(kind=8), device, allocatable, dimension(:) :: p
17+
1618
contains
1719
function dev1(a)
1820
integer, device :: a(:)
@@ -456,3 +458,19 @@ end
456458
! CHECK: %[[M:.*]]:2 = hlfir.declare %4 {data_attr = #cuf.cuda<managed>, uniq_name = "_QFsub24Em"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
457459
! CHECK: %[[D1:.*]] = hlfir.designate %[[D]]#0 (%c1{{.*}}) : (!fir.ref<!fir.array<4xf32>>, index) -> !fir.ref<f32>
458460
! CHECK: cuf.data_transfer %[[D1]] to %[[M]]#0 {transfer_kind = #cuf.cuda_transfer<device_device>} : !fir.ref<f32>, !fir.ref<f32>
461+
462+
subroutine sub25()
463+
use mod1
464+
integer :: i
465+
real(8) :: c
466+
467+
do i = 1, 10
468+
c = c + p(i)
469+
end do
470+
end
471+
472+
! CHECK-LABEL: func.func @_QPsub25()
473+
! CHECK: fir.allocmem !fir.array<?xf64>, %15#1 {bindc_name = ".tmp", uniq_name = ""}
474+
! CHECK: cuf.data_transfer %{{.*}} to %{{.*}} {transfer_kind = #cuf.cuda_transfer<device_host>} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, !fir.box<!fir.array<?xf64>>
475+
! CHECK: hlfir.assign %{{.*}} to %{{.*}} : f64, !fir.ref<f64>
476+
! CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<?xf64>>

libc/include/dlfcn.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ enums:
4646
standards:
4747
- gnu
4848
value: 2
49-
- name: RTLD_DI_CONFIGADDR,
49+
- name: RTLD_DI_CONFIGADDR
5050
standards:
5151
- gnu
5252
value: 3
@@ -127,5 +127,5 @@ functions:
127127
- POSIX
128128
return_type: int
129129
arguments:
130-
- type: const void *
131-
- type: Dl_info *
130+
- type: const void *__restrict
131+
- type: Dl_info *__restrict

libc/src/dlfcn/dladdr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
namespace LIBC_NAMESPACE_DECL {
1515

1616
// TODO: https:// github.com/llvm/llvm-project/issues/97929
17-
LLVM_LIBC_FUNCTION(int, dladdr, (const void *addr, Dl_info *info)) {
17+
LLVM_LIBC_FUNCTION(int, dladdr,
18+
(const void *__restrict addr, Dl_info *__restrict info)) {
1819
return -1;
1920
}
2021

libc/src/dlfcn/dladdr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace LIBC_NAMESPACE_DECL {
1515

16-
int dladdr(const void *, Dl_info *);
16+
int dladdr(const void *__restrict, Dl_info *__restrict);
1717

1818
} // namespace LIBC_NAMESPACE_DECL
1919

libc/src/dlfcn/dlinfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ namespace LIBC_NAMESPACE_DECL {
1616

1717
// TODO: https://github.com/llvm/llvm-project/issues/149911
1818
LLVM_LIBC_FUNCTION(int, dlinfo,
19-
(void *restrict handle, int request, void *restrict info)) {
19+
(void *__restrict handle, int request,
20+
void *__restrict info)) {
2021
return -1;
2122
}
2223

libc/src/dlfcn/dlinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace LIBC_NAMESPACE_DECL {
1515

16-
int dlinfo(void *restrict, int, void *restrict);
16+
int dlinfo(void *__restrict, int, void *__restrict);
1717

1818
} // namespace LIBC_NAMESPACE_DECL
1919

libc/src/dlfcn/dlsym.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace LIBC_NAMESPACE_DECL {
1515

1616
// TODO(@izaakschroeder): https://github.com/llvm/llvm-project/issues/97920
17-
LLVM_LIBC_FUNCTION(void *, dlsym, (void *, const char *)) { return nullptr; }
17+
LLVM_LIBC_FUNCTION(void *, dlsym, (void *__restrict, const char *__restrict)) {
18+
return nullptr;
19+
}
1820

1921
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)