Skip to content

Commit 56f0102

Browse files
devajithvsRoot Persona
authored andcommitted
Add support for SYCL with adaptiveCpp
AdaptiveCpp requires NullDerefProtectionTransformer to be turned off to function properly
1 parent 6c0c362 commit 56f0102

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

lib/Interpreter/BackendPasses.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636

3737
#include <optional>
3838

39+
#ifdef CLING_WITH_ADAPTIVECPP
40+
llvm::PassPluginLibraryInfo getAdaptiveCppPluginInfo();
41+
#endif
42+
3943
using namespace cling;
4044
using namespace clang;
4145
using namespace llvm;
@@ -511,6 +515,10 @@ void BackendPasses::CreatePasses(int OptLevel, llvm::ModulePassManager& MPM,
511515
std::optional<PGOOptions> PGOOpt;
512516
PassBuilder PB(&m_TM, PTO, PGOOpt, &PIC);
513517

518+
#ifdef CLING_WITH_ADAPTIVECPP
519+
getAdaptiveCppPluginInfo().RegisterPassBuilderCallbacks(PB);
520+
#endif
521+
514522
// Attempt to load pass plugins and register their callbacks with PB.
515523
for (auto& PluginFN : m_CGOpts.PassPlugins) {
516524
auto PassPlugin = PassPlugin::Load(PluginFN);

lib/Interpreter/CIFactory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,11 @@ namespace {
13911391
argvCompile.push_back("-fno-omit-frame-pointer");
13921392
}
13931393

1394+
#ifdef CLING_WITH_ADAPTIVECPP
1395+
argvCompile.push_back("-D__ACPP_ENABLE_LLVM_SSCP_TARGET__");
1396+
argvCompile.push_back("-Xclang");
1397+
argvCompile.push_back("-disable-O0-optnone");
1398+
#endif
13941399
// Add host specific includes, -resource-dir if necessary, and -isysroot
13951400
std::string ClingBin = GetExecutablePath(argv[0]);
13961401
AddHostArguments(ClingBin, argvCompile, LLVMDir, COpts);

lib/Interpreter/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ set(LIBS
2323
clangLex
2424
)
2525

26+
if(experimental_adaptivecpp)
27+
list(APPEND LIBS AdaptiveCpp acpp-rt)
28+
29+
set(ACPP_EXPORTS acpp-rt acpp-common)
30+
31+
foreach(target IN LISTS ACPP_EXPORTS)
32+
install(TARGETS ${target} EXPORT ClingTargets)
33+
endforeach()
34+
35+
set_property(GLOBAL APPEND PROPERTY CLING_EXPORTS ${ACPP_EXPORTS})
36+
endif()
37+
2638
set(LLVM_LINK_COMPONENTS
2739
analysis
2840
core

lib/Interpreter/IncrementalParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,9 +1033,11 @@ namespace cling {
10331033
// Don't protect against crashes if we cannot run anything.
10341034
// cling might also be in a PCH-generation mode; don't inject our Sema
10351035
// pointer into the PCH.
1036+
#ifndef CLING_WITH_ADAPTIVECPP
10361037
if (!isCUDADevice && m_Interpreter->getOptions().PtrCheck)
10371038
ASTTransformers.emplace_back(
10381039
new NullDerefProtectionTransformer(m_Interpreter));
1040+
#endif
10391041
if (isCUDADevice)
10401042
ASTTransformers.emplace_back(
10411043
new DeviceKernelInliner(TheSema));

0 commit comments

Comments
 (0)