Skip to content

Commit 43ff03a

Browse files
committed
Address review comments
1 parent 4f9041b commit 43ff03a

File tree

7 files changed

+17
-33
lines changed

7 files changed

+17
-33
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
15741574
options::OPT_fno_profile_generate, // -f[no-]profile-generate
15751575
options::OPT_ftest_coverage,
15761576
options::OPT_fno_test_coverage, // -f[no-]test-coverage
1577+
options::OPT_coverage, // --coverage
15771578
options::OPT_fprofile_arcs,
15781579
options::OPT_fno_profile_arcs, // -f[no-]profile-arcs
15791580
options::OPT_fno_profile_instr_generate, // -f[no-]profile-instr-generate

clang/test/Driver/sycl-unsupported.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
2020
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
2121

22-
// RUN: %clangxx -fsycl -fprofile-instr-generate -### %s 2>&1 \
23-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate \
24-
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
25-
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
26-
// RUN: %clangxx -fsycl -fcoverage-mapping \
27-
// RUN: -fprofile-instr-generate -### %s 2>&1 \
28-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fcoverage-mapping
2922
// RUN: %clangxx -fsycl -ftest-coverage -### %s 2>&1 \
3023
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-ftest-coverage \
3124
// RUN: -DOPT_CC1=-coverage-notes-file \
@@ -49,12 +42,6 @@
4942
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=--coverage \
5043
// RUN: -DOPT_CC1=-coverage-notes-file \
5144
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
52-
// Check to make sure our '-fsanitize=address' exception isn't triggered by a
53-
// different option
54-
// RUN: %clangxx -fsycl -fprofile-instr-generate=address -### %s 2>&1 \
55-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate=address \
56-
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
57-
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
5845

5946
// CHECK: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}'; only supported for host compilation [-Woption-ignored]
6047
// CHECK-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "[[OPT]]{{.*}}"

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,10 @@ Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) {
11261126
Counters, "pgocount.addr");
11271127
const std::uint64_t Index = I->getIndex()->getZExtValue();
11281128
if (Index > 0) {
1129-
auto *Offset = Builder.getInt64(I->getIndex()->getZExtValue());
1130-
auto *AddrWithOffset = Builder.CreateGEP(Type::getInt64Ty(M.getContext()),
1131-
Addr, Offset, "pgocount.addr");
1129+
auto *Offset = Builder.getInt64(I->getIndex()->getZExtValue() *
1130+
sizeof(std::uint64_t));
1131+
auto *AddrWithOffset =
1132+
Builder.CreatePtrAdd(Addr, Offset, "pgocount.offset");
11321133
return AddrWithOffset;
11331134
}
11341135
return Addr;
@@ -1686,12 +1687,7 @@ InstrLowerer::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
16861687
Constant::getNullValue(StructTy), Name);
16871688
const std::uint64_t FnHash = IndexedInstrProf::ComputeHash(
16881689
getPGOFuncNameVarInitializer(Inc->getName()));
1689-
const std::string FnName = [&] {
1690-
auto *Arr = cast<ConstantDataArray>(Inc->getName()->getInitializer());
1691-
StringRef NameStr =
1692-
Arr->isCString() ? Arr->getAsCString() : Arr->getAsString();
1693-
return std::string{"__profc_"} + std::to_string(FnHash);
1694-
}();
1690+
const std::string FnName = std::string{"__profc_"} + std::to_string(FnHash);
16951691
GV->addAttribute("sycl-unique-id", FnName);
16961692
GV->addAttribute("sycl-device-global-size", Twine(NumCounters * 8).str());
16971693
return GV;

sycl/source/detail/device_global_map_entry.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,21 @@ void DeviceGlobalMapEntry::cleanupProfileCounter(context_impl *CtxImpl) {
7979
return std::strtoull(MUniqueId.substr(PrefixSize).c_str(), nullptr,
8080
DecimalBase);
8181
}();
82-
for (device_impl &Device : CtxImpl->getDevices()) {
82+
for (const device_impl &Device : CtxImpl->getDevices()) {
8383
auto USMPtrIt = MDeviceToUSMPtrMap.find({&Device, CtxImpl});
8484
if (USMPtrIt != MDeviceToUSMPtrMap.end()) {
8585
DeviceGlobalUSMMem &USMMem = USMPtrIt->second;
8686

87-
// Get the increments from the USM pointer
87+
// Get the increments from the USM pointer.
8888
std::vector<std::uint64_t> Increments(NumCounters);
8989
const std::uint64_t *Counters = static_cast<std::uint64_t *>(USMMem.MPtr);
9090
for (std::size_t I = 0; I < NumCounters; ++I)
91-
Increments[I] += Counters[I];
91+
Increments[I] = Counters[I];
9292

93-
// Call the weak symbol to update the profile counters
94-
if (__sycl_increment_profile_counters) {
93+
// Call the weak symbol to update the profile counters.
94+
if (__sycl_increment_profile_counters)
9595
__sycl_increment_profile_counters(FnHash, Increments.size(),
9696
Increments.data());
97-
}
9897

9998
// Free the USM memory and release the event if it exists.
10099
detail::usm::freeInternal(USMMem.MPtr, CtxImpl);

sycl/source/detail/device_global_map_entry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct DeviceGlobalMapEntry {
116116
// Returns true if the device_global is a profile counter.
117117
bool isProfileCounter();
118118

119-
// Cleans up a profile counter device global
119+
// Cleans up a profile counter device global.
120120
void cleanupProfileCounter(context_impl *CtxImpl);
121121

122122
// Gets or allocates USM memory for a device_global.

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ std::vector<DeviceGlobalMapEntry *> ProgramManager::getDeviceGlobalEntries(
24692469
std::vector<DeviceGlobalMapEntry *>
24702470
ProgramManager::getProfileCounterDeviceGlobalEntries(
24712471
const context_impl *CtxImpl) {
2472-
std::vector<DeviceGlobalMapEntry *> ProfileCounters =
2472+
const std::vector<DeviceGlobalMapEntry *> ProfileCounters =
24732473
ProgramManager::getInstance().m_DeviceGlobals.getProfileCounterEntries();
24742474
std::vector<DeviceGlobalMapEntry *> FoundEntries;
24752475
for (const auto &DGEntry : ProfileCounters) {

sycl/test-e2e/Basic/device_code_coverage.cpp renamed to sycl/test-e2e/Coverage/device_code_coverage.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -fprofile-instr-generate -fcoverage-mapping -o %t.out
22
// RUN: %{run} LLVM_PROFILE_FILE=%t.profraw %t.out
3-
// RUN: llvm-profdata merge %t.profraw -o %t.profdata
4-
// RUN: llvm-cov show -instr-profile=%t.profdata %t.out -name="main" | FileCheck %s
3+
// RUN: %{run-aux} llvm-profdata merge %t.profraw -o %t.profdata
4+
// RUN: %{run-aux} llvm-cov show -instr-profile=%t.profdata %t.out -name="main" | FileCheck %s
55

6-
#include <sycl/sycl.hpp>
6+
#include <sycl/usm.hpp>
77

88
int main() {
99
sycl::queue q;
@@ -22,6 +22,7 @@ int main() {
2222
return 0;
2323
}
2424

25+
// REQUIRES: target-spir
2526
// UNSUPPORTED: opencl && gpu
2627
// UNSUPPORTED-TRACKER: GSD-4287
2728

0 commit comments

Comments
 (0)