Skip to content

Commit

Permalink
Drop copied transformation from sycl-post-link
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Oppermann <[email protected]>
  • Loading branch information
jopperm committed Nov 25, 2024
1 parent ec89eeb commit ffdb197
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 177 deletions.
1 change: 0 additions & 1 deletion sycl-jit/jit-compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ add_llvm_library(sycl-jit
lib/fusion/JITContext.cpp
lib/fusion/ModuleHelper.cpp
lib/rtc/DeviceCompilation.cpp
lib/rtc/PostLinkActions.cpp
lib/helper/ConfigHelper.cpp

SHARED
Expand Down
33 changes: 16 additions & 17 deletions sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include "DeviceCompilation.h"

#include "PostLinkActions.h"

#include <clang/Basic/DiagnosticDriver.h>
#include <clang/Basic/Version.h>
#include <clang/CodeGen/CodeGenAction.h>
Expand All @@ -20,6 +18,8 @@
#include <clang/Tooling/CompilationDatabase.h>
#include <clang/Tooling/Tooling.h>

#include <llvm/IR/PassInstrumentation.h>
#include <llvm/IR/PassManager.h>
#include <llvm/IRReader/IRReader.h>
#include <llvm/Linker/Linker.h>
#include <llvm/SYCLLowerIR/ComputeModuleRuntimeInfo.h>
Expand All @@ -37,7 +37,6 @@ using namespace llvm::sycl;
using namespace llvm::module_split;
using namespace llvm::util;
using namespace jit_compiler;
using namespace jit_compiler::post_link;

#ifdef _GNU_SOURCE
#include <dlfcn.h>
Expand Down Expand Up @@ -365,26 +364,26 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
return Error::success();
}

template <class PassClass> static bool runModulePass(llvm::Module &M) {
ModulePassManager MPM;
ModuleAnalysisManager MAM;
// Register required analysis
MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
MPM.addPass(PassClass{});
PreservedAnalyses Res = MPM.run(M, MAM);
return !Res.areAllPreserved();
}

Expected<RTCBundleInfo> jit_compiler::performPostLink(
llvm::Module &Module, [[maybe_unused]] const InputArgList &UserArgList) {
// This is a simplified version of `processInputModule` in
// `llvm/tools/sycl-post-link.cpp`. Assertions/TODOs point to functionality
// left out of the algorithm for now.

// After linking device bitcode "llvm.used" holds references to the kernels
// that are defined in the device image. But after splitting device image into
// separate kernels we may end up with having references to kernel declaration
// originating from "llvm.used" in the IR that is passed to llvm-spirv tool,
// and these declarations cause an assertion in llvm-spirv. To workaround this
// issue remove "llvm.used" from the input module before performing any other
// actions.
removeSYCLKernelsConstRefArray(Module);

// There may be device_global variables kept alive in "llvm.compiler.used"
// to keep the optimizer from wrongfully removing them. llvm.compiler.used
// symbols are usually removed at backend lowering, but this is handled here
// for SPIR-V since SYCL compilation uses llvm-spirv, not the SPIR-V backend.
removeDeviceGlobalFromCompilerUsed(Module);
assert(!Module.getGlobalVariable("llvm.used") &&
!Module.getGlobalVariable("llvm.compiler.used"));
// Otherwise: Port over the `removeSYCLKernelsConstRefArray` and
// `removeDeviceGlobalFromCompilerUsed` methods.

assert(!isModuleUsingAsan(Module));
// Otherwise: Need to instrument each image scope device globals if the module
Expand Down
109 changes: 0 additions & 109 deletions sycl-jit/jit-compiler/lib/rtc/PostLinkActions.cpp

This file was deleted.

50 changes: 0 additions & 50 deletions sycl-jit/jit-compiler/lib/rtc/PostLinkActions.h

This file was deleted.

0 comments on commit ffdb197

Please sign in to comment.