Skip to content

Commit ffdb197

Browse files
committed
Drop copied transformation from sycl-post-link
Signed-off-by: Julian Oppermann <[email protected]>
1 parent ec89eeb commit ffdb197

File tree

4 files changed

+16
-177
lines changed

4 files changed

+16
-177
lines changed

sycl-jit/jit-compiler/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ add_llvm_library(sycl-jit
88
lib/fusion/JITContext.cpp
99
lib/fusion/ModuleHelper.cpp
1010
lib/rtc/DeviceCompilation.cpp
11-
lib/rtc/PostLinkActions.cpp
1211
lib/helper/ConfigHelper.cpp
1312

1413
SHARED

sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include "DeviceCompilation.h"
1010

11-
#include "PostLinkActions.h"
12-
1311
#include <clang/Basic/DiagnosticDriver.h>
1412
#include <clang/Basic/Version.h>
1513
#include <clang/CodeGen/CodeGenAction.h>
@@ -20,6 +18,8 @@
2018
#include <clang/Tooling/CompilationDatabase.h>
2119
#include <clang/Tooling/Tooling.h>
2220

21+
#include <llvm/IR/PassInstrumentation.h>
22+
#include <llvm/IR/PassManager.h>
2323
#include <llvm/IRReader/IRReader.h>
2424
#include <llvm/Linker/Linker.h>
2525
#include <llvm/SYCLLowerIR/ComputeModuleRuntimeInfo.h>
@@ -37,7 +37,6 @@ using namespace llvm::sycl;
3737
using namespace llvm::module_split;
3838
using namespace llvm::util;
3939
using namespace jit_compiler;
40-
using namespace jit_compiler::post_link;
4140

4241
#ifdef _GNU_SOURCE
4342
#include <dlfcn.h>
@@ -365,26 +364,26 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
365364
return Error::success();
366365
}
367366

367+
template <class PassClass> static bool runModulePass(llvm::Module &M) {
368+
ModulePassManager MPM;
369+
ModuleAnalysisManager MAM;
370+
// Register required analysis
371+
MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
372+
MPM.addPass(PassClass{});
373+
PreservedAnalyses Res = MPM.run(M, MAM);
374+
return !Res.areAllPreserved();
375+
}
376+
368377
Expected<RTCBundleInfo> jit_compiler::performPostLink(
369378
llvm::Module &Module, [[maybe_unused]] const InputArgList &UserArgList) {
370379
// This is a simplified version of `processInputModule` in
371380
// `llvm/tools/sycl-post-link.cpp`. Assertions/TODOs point to functionality
372381
// left out of the algorithm for now.
373382

374-
// After linking device bitcode "llvm.used" holds references to the kernels
375-
// that are defined in the device image. But after splitting device image into
376-
// separate kernels we may end up with having references to kernel declaration
377-
// originating from "llvm.used" in the IR that is passed to llvm-spirv tool,
378-
// and these declarations cause an assertion in llvm-spirv. To workaround this
379-
// issue remove "llvm.used" from the input module before performing any other
380-
// actions.
381-
removeSYCLKernelsConstRefArray(Module);
382-
383-
// There may be device_global variables kept alive in "llvm.compiler.used"
384-
// to keep the optimizer from wrongfully removing them. llvm.compiler.used
385-
// symbols are usually removed at backend lowering, but this is handled here
386-
// for SPIR-V since SYCL compilation uses llvm-spirv, not the SPIR-V backend.
387-
removeDeviceGlobalFromCompilerUsed(Module);
383+
assert(!Module.getGlobalVariable("llvm.used") &&
384+
!Module.getGlobalVariable("llvm.compiler.used"));
385+
// Otherwise: Port over the `removeSYCLKernelsConstRefArray` and
386+
// `removeDeviceGlobalFromCompilerUsed` methods.
388387

389388
assert(!isModuleUsingAsan(Module));
390389
// Otherwise: Need to instrument each image scope device globals if the module

sycl-jit/jit-compiler/lib/rtc/PostLinkActions.cpp

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

sycl-jit/jit-compiler/lib/rtc/PostLinkActions.h

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

0 commit comments

Comments
 (0)