Skip to content

Commit 5a9aa8b

Browse files
Revert "[SYCL] Implement coverage instrumentation for device code" (#20442)
Reverts #20206. This is believed to cause issues in both post-commit testing (unittest failures and build failures on macOS) and in RHEL build pre-commit testing due to issues with compiler-rt.
1 parent 200ca34 commit 5a9aa8b

File tree

17 files changed

+43
-370
lines changed

17 files changed

+43
-370
lines changed

buildbot/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def do_configure(args, passthrough_args):
2121
if not os.path.isdir(abs_obj_dir):
2222
os.makedirs(abs_obj_dir)
2323

24-
llvm_external_projects = "sycl;llvm-spirv;opencl;xpti;xptifw;compiler-rt"
24+
llvm_external_projects = "sycl;llvm-spirv;opencl;xpti;xptifw"
2525

2626
# libdevice build requires a working SYCL toolchain, which is not the case
2727
# with macOS target right now.

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,9 +5480,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54805480
CmdArgs.push_back("-fsycl-is-device");
54815481
CmdArgs.push_back("-fdeclare-spirv-builtins");
54825482

5483-
// Set the atomic profile update flag to increment counters atomically.
5484-
CmdArgs.push_back("-fprofile-update=atomic");
5485-
54865483
// Set O2 optimization level by default
54875484
if (!Args.getLastArg(options::OPT_O_Group))
54885485
CmdArgs.push_back("-O2");

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,11 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
15751575
options::OPT_fno_profile_generate, // -f[no-]profile-generate
15761576
options::OPT_ftest_coverage,
15771577
options::OPT_fno_test_coverage, // -f[no-]test-coverage
1578-
options::OPT_coverage, // --coverage
1578+
options::OPT_fcoverage_mapping,
1579+
options::OPT_coverage, // --coverage
1580+
options::OPT_fno_coverage_mapping, // -f[no-]coverage-mapping
1581+
options::OPT_fprofile_instr_generate,
1582+
options::OPT_fprofile_instr_generate_EQ,
15791583
options::OPT_fprofile_arcs,
15801584
options::OPT_fno_profile_arcs, // -f[no-]profile-arcs
15811585
options::OPT_fno_profile_instr_generate, // -f[no-]profile-instr-generate

clang/test/Driver/sycl-unsupported.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
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
2229
// RUN: %clangxx -fsycl -ftest-coverage -### %s 2>&1 \
2330
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-ftest-coverage \
2431
// RUN: -DOPT_CC1=-coverage-notes-file \
@@ -42,6 +49,12 @@
4249
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=--coverage \
4350
// RUN: -DOPT_CC1=-coverage-notes-file \
4451
// 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
4558

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

compiler-rt/lib/profile/InstrProfilingRuntime.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@ extern "C" {
1010

1111
#include "InstrProfiling.h"
1212

13-
void __sycl_increment_profile_counters(uint64_t FnHash, size_t NumCounters,
14-
const uint64_t *Increments) {
15-
for (const __llvm_profile_data *DataVar = __llvm_profile_begin_data();
16-
DataVar < __llvm_profile_end_data(); DataVar++) {
17-
if (DataVar->NameRef != FnHash || DataVar->NumCounters != NumCounters)
18-
continue;
19-
20-
uint64_t *const Counters = reinterpret_cast<uint64_t *>(
21-
reinterpret_cast<uintptr_t>(DataVar) +
22-
reinterpret_cast<uintptr_t>(DataVar->CounterPtr));
23-
for (size_t i = 0; i < NumCounters; i++)
24-
Counters[i] += Increments[i];
25-
break;
26-
}
27-
}
28-
2913
static int RegisterRuntime() {
3014
__llvm_profile_initialize();
3115
#ifdef _AIX

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,9 +1002,6 @@ bool InstrLowerer::lower() {
10021002
if (!NeedsRuntimeHook && ContainsProfiling)
10031003
emitRuntimeHook();
10041004

1005-
if (M.getTargetTriple().isSPIR())
1006-
return true;
1007-
10081005
emitRegistration();
10091006
emitUses();
10101007
emitInitialization();
@@ -1119,18 +1116,6 @@ GlobalVariable *InstrLowerer::getOrCreateBiasVar(StringRef VarName) {
11191116
}
11201117

11211118
Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) {
1122-
if (M.getTargetTriple().isSPIR()) {
1123-
auto *Counters = getOrCreateRegionCounters(I);
1124-
IRBuilder<> Builder(I);
1125-
auto *Addr = Builder.CreateLoad(PointerType::get(M.getContext(), 1),
1126-
Counters, "pgocount.addr");
1127-
const std::uint64_t Index = I->getIndex()->getZExtValue();
1128-
if (Index == 0)
1129-
return Addr;
1130-
auto *Offset = Builder.getInt64(Index * sizeof(std::uint64_t));
1131-
return Builder.CreatePtrAdd(Addr, Offset, "pgocount.offset");
1132-
}
1133-
11341119
auto *Counters = getOrCreateRegionCounters(I);
11351120
IRBuilder<> Builder(I);
11361121

@@ -1672,22 +1657,6 @@ InstrLowerer::getOrCreateRegionBitmaps(InstrProfMCDCBitmapInstBase *Inc) {
16721657
GlobalVariable *
16731658
InstrLowerer::createRegionCounters(InstrProfCntrInstBase *Inc, StringRef Name,
16741659
GlobalValue::LinkageTypes Linkage) {
1675-
if (M.getTargetTriple().isSPIR()) {
1676-
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
1677-
auto &Ctx = M.getContext();
1678-
auto *PtrTy = PointerType::get(Ctx, 1);
1679-
auto *IntTy = Type::getInt64Ty(Ctx);
1680-
auto *StructTy = StructType::get(Ctx, {PtrTy, IntTy});
1681-
GlobalVariable *GV = new GlobalVariable(
1682-
M, StructTy, false, Linkage, Constant::getNullValue(StructTy), Name);
1683-
const std::uint64_t FnHash = IndexedInstrProf::ComputeHash(
1684-
getPGOFuncNameVarInitializer(Inc->getName()));
1685-
const std::string FnName = std::string{"__profc_"} + std::to_string(FnHash);
1686-
GV->addAttribute("sycl-unique-id", FnName);
1687-
GV->addAttribute("sycl-device-global-size", Twine(NumCounters * 8).str());
1688-
return GV;
1689-
}
1690-
16911660
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
16921661
auto &Ctx = M.getContext();
16931662
GlobalVariable *GV;

llvm/test/Instrumentation/InstrProfiling/coverage_sycl.ll

Lines changed: 0 additions & 29 deletions
This file was deleted.

sycl/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,13 @@ add_custom_target(sycl-compiler
389389
clang-offload-extract
390390
clang-offload-packager
391391
clang-linker-wrapper
392-
compiler-rt
393392
file-table-tform
394393
llc
395394
llvm-ar
396395
llvm-foreach
397396
llvm-spirv
398397
llvm-link
399398
llvm-objcopy
400-
llvm-profdata
401-
llvm-cov
402399
spirv-to-ir-wrapper
403400
sycl-post-link
404401
opencl-aot

sycl/doc/design/DeviceCodeCoverage.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

sycl/doc/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Design Documents for the oneAPI DPC++ Compiler
4040
design/ParallelForRangeRounding
4141
design/SYCLInstrumentationUsingXPTI
4242
design/ITTAnnotations
43-
design/DeviceCodeCoverage
4443
design/DeviceGlobal
4544
design/CompileTimeProperties
4645
design/HostPipes

0 commit comments

Comments
 (0)