Skip to content

Commit 2540696

Browse files
sarnexcalebwat
authored andcommitted
[SYCL][thinLTO] Seperate module properties and symbol table generation into IR-based analysis (#14220)
Based on feedback from #14197, I seperated out the code that generates the module properties and symbol table into separate functions that can be called by anyone, and just looks at the IR and entry points. For now, we still call it inside `sycl-post-link` because we still support the old offloading model, but once we drop support for that we can drop this responsibility from sycl-post-link and only compute it inside `clang-linker-wrapper`, both for normal compilation and thinLTO. In a (hopefully soon) future PR I plan to call these functions from `clang-linker-wrapper` when compiling for thinLTO, which we need because we will split early. Most of this change should be NFC(I). The expected changes are: 1) New option to sycl-post-link to generate the properties file 2) Driver change to NOT pass the option from 1) in thinLTO mode 3) Two minor chages in logic from properties generation, I've called these out inline. --------- Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 5465207 commit 2540696

File tree

154 files changed

+732
-600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+732
-600
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10701,6 +10701,11 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1070110701
if (TCArgs.hasFlag(options::OPT_fno_sycl_esimd_force_stateless_mem,
1070210702
options::OPT_fsycl_esimd_force_stateless_mem, false))
1070310703
addArgs(PostLinkArgs, TCArgs, {"-lower-esimd-force-stateless-mem=false"});
10704+
10705+
bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
10706+
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
10707+
if (!IsUsingLTO || LTOMode != LTOK_Thin)
10708+
addArgs(PostLinkArgs, TCArgs, {"-properties"});
1070410709
}
1070510710

1070610711
// Add any sycl-post-link options that rely on a specific Triple in addition
@@ -10755,9 +10760,12 @@ static void getTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1075510760
bool SplitEsimd = TCArgs.hasFlag(
1075610761
options::OPT_fsycl_device_code_split_esimd,
1075710762
options::OPT_fno_sycl_device_code_split_esimd, SplitEsimdByDefault);
10758-
// Symbol file and specialization constant info generation is mandatory -
10763+
bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
10764+
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
10765+
if (!IsUsingLTO || LTOMode != LTOK_Thin)
10766+
addArgs(PostLinkArgs, TCArgs, {"-symbols"});
10767+
// Specialization constant info generation is mandatory -
1075910768
// add options unconditionally
10760-
addArgs(PostLinkArgs, TCArgs, {"-symbols"});
1076110769
addArgs(PostLinkArgs, TCArgs, {"-emit-exported-symbols"});
1076210770
addArgs(PostLinkArgs, TCArgs, {"-emit-imported-symbols"});
1076310771
if (SplitEsimd)

clang/test/Driver/sycl-linker-wrapper-image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: clang-offload-packager -o %t.fat --image=file=%t.device.bc,kind=sycl,triple=spir64-unknown-unknown
66
// RUN: %clang -cc1 %s -triple=x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.fat
77
// RUN: clang-linker-wrapper --print-wrapped-module --host-triple=x86_64-unknown-linux-gnu \
8-
// RUN: -sycl-device-library-location=%S/Inputs -sycl-post-link-options="-split=auto -symbols" \
8+
// RUN: -sycl-device-library-location=%S/Inputs -sycl-post-link-options="-split=auto -symbols -properties" \
99
// RUN: %t.o -o %t.out 2>&1 --linker-path="/usr/bin/ld" | FileCheck %s
1010

1111
template <typename t, typename Func>

clang/test/Driver/sycl-lto.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// RUN: %clangxx -fsycl --offload-new-driver -foffload-lto=thin %s -### 2>&1 | FileCheck -check-prefix=CHECK_SUPPORTED %s
1313
// CHECK_SUPPORTED: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown" {{.*}} "-flto=thin" "-flto-unit"
1414
// CHECK_SUPPORTED: sycl-post-link{{.*}}
15+
// CHECK_SUPPORTED-NOT: -properties
1516
// CHECK_SUPPORTED-NEXT: file-table-tform{{.*}}
1617
// CHECK_SUPPORTED-NEXT: llvm-foreach{{.*}} "--" {{.*}}clang{{.*}} "-fsycl-is-device"{{.*}} "-flto=thin" "-flto-unit"
1718
// CHECK_SUPPORTED-NEXT: file-table-tform{{.*}}

clang/test/Driver/sycl-offload-intelfpga-emu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
// CHK-FPGA-AOCX-SRC: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" {{.*}} "-target=spir64_fpga" "-kind=sycl" "--sym-prop-bc-files=[[SYM_AND_PROP]]" "-batch" "[[TABLEOUT]]"
179179
// CHK-FPGA-AOCX-SRC: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.(o|obj)]]" "[[WRAPOUT]]"
180180
// CHK-FPGA-AOCX-SRC: llvm-link{{.*}} "[[DEVICEBC]]" "-o" "[[LLVMLINKOUT:.+\.bc]]" "--suppress-warnings"
181-
// CHK-FPGA-AOCX-SRC: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
181+
// CHK-FPGA-AOCX-SRC: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
182182
// CHK-FPGA-AOCX-SRC: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[POSTLINKOUT]]"
183183
// CHK-FPGA-AOCX-SRC: llvm-spirv{{.*}} "-o" "[[LLVMSPVOUT:.+\.txt]]" {{.*}} "[[TABLEOUT]]"
184184
// CHK-FPGA-AOCX-SRC: opencl-aot{{.*}} "-device=fpga_fast_emu" "-spv=[[LLVMSPVOUT]]" "-ir=[[OUTPUT4:.+\.aocx]]" "--bo=-g"

clang/test/Driver/sycl-offload-intelfpga-link.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// CHK-FPGA-LINK-NOT: clang-offload-bundler{{.*}}
1414
// CHK-FPGA-LINK: spirv-to-ir-wrapper{{.*}} "[[OUTPUT1]]" "-o" "[[IROUTPUT1:.+\.bc]]"
1515
// CHK-FPGA-LINK: llvm-link{{.*}} "[[IROUTPUT1]]" "-o" "[[OUTPUT2_1:.+\.bc]]"
16-
// CHK-FPGA-LINK: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT2:.+\.table]]" "[[OUTPUT2_1]]"
16+
// CHK-FPGA-LINK: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT2:.+\.table]]" "[[OUTPUT2_1]]"
1717
// CHK-FPGA-LINK: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[OUTPUT2]]"
1818
// CHK-FPGA-LINK: llvm-spirv{{.*}} "-o" "[[OUTPUT3:.+\.txt]]" "-spirv-max-version={{.*}}"{{.*}} "[[TABLEOUT]]"
1919
// CHK-FPGA-EARLY: aoc{{.*}} "-o" "[[OUTPUT4:.+\.aocr]]" "[[OUTPUT3]]" "-sycl" "-rtl"
@@ -46,7 +46,7 @@
4646
// CHK-FPGA-LINK-WIN-NOT: clang-offload-bundler{{.*}}
4747
// CHK-FPGA-LINK-WIN: spirv-to-ir-wrapper{{.*}} "[[OUTPUT1]]" "-o" "[[IROUTPUT1:.+\.bc]]"
4848
// CHK-FPGA-LINK-WIN: llvm-link{{.*}} "[[IROUTPUT1]]" "-o" "[[OUTPUT2_1:.+\.bc]]"
49-
// CHK-FPGA-LINK-WIN: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT2:.+\.table]]" "[[OUTPUT2_1]]"
49+
// CHK-FPGA-LINK-WIN: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT2:.+\.table]]" "[[OUTPUT2_1]]"
5050
// CHK-FPGA-LINK-WIN: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[OUTPUT2]]"
5151
// CHK-FPGA-LINK-WIN: llvm-spirv{{.*}} "-o" "[[OUTPUT3:.+\.txt]]" "-spirv-max-version={{.*}}"{{.*}} "[[TABLEOUT]]"
5252
// CHK-FPGA-LINK-WIN: aoc{{.*}} "-o" "[[OUTPUT5:.+\.aocr]]" "[[OUTPUT3]]" "-sycl" "-rtl"
@@ -175,7 +175,7 @@
175175
// CHK-FPGA: clang-offload-bundler{{.*}} "-type=o" "-targets=host-x86_64-unknown-linux-gnu,sycl-spir64_fpga-unknown-unknown" {{.*}} "-output=[[FINALLINK2x:.+\.o]]" "-output=[[OUTPUT1:.+\.o]]" "-unbundle"
176176
// CHK-FPGA: spirv-to-ir-wrapper{{.*}} "[[OUTPUT1]]" "-o" "[[IROUTPUT1:.+\.bc]]"
177177
// CHK-FPGA: llvm-link{{.*}} "[[IROUTPUT1]]" "-o" "[[OUTPUT2_BC:.+\.bc]]"
178-
// CHK-FPGA: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT3_TABLE:.+\.table]]" "[[OUTPUT2_BC]]"
178+
// CHK-FPGA: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[OUTPUT3_TABLE:.+\.table]]" "[[OUTPUT2_BC]]"
179179
// CHK-FPGA: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[OUTPUT3_TABLE]]"
180180
// CHK-FPGA: llvm-spirv{{.*}} "-o" "[[OUTPUT5:.+\.txt]]" "-spirv-max-version={{.*}}"{{.*}} "[[TABLEOUT]]"
181181
// CHK-FPGA: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-fpga_dep" {{.*}} "-output=[[DEPFILE:.+\.d]]" "-unbundle"
@@ -237,7 +237,7 @@
237237
// CHK-FPGA-AOCX-SRC: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" {{.*}} "-target=spir64_fpga" "-kind=sycl" "--sym-prop-bc-files=[[SYM_AND_PROP]]" "-batch" "[[TABLEOUT]]"
238238
// CHK-FPGA-AOCX-SRC: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.(o|obj)]]" "[[WRAPOUT]]"
239239
// CHK-FPGA-AOCX-SRC: llvm-link{{.*}} "[[DEVICEBC]]" "-o" "[[LLVMLINKOUT:.+\.bc]]" "--suppress-warnings"
240-
// CHK-FPGA-AOCX-SRC: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
240+
// CHK-FPGA-AOCX-SRC: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
241241
// CHK-FPGA-AOCX-SRC: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[POSTLINKOUT]]"
242242
// CHK-FPGA-AOCX-SRC: llvm-spirv{{.*}} "-o" "[[LLVMSPVOUT:.+\.txt]]" {{.*}} "[[TABLEOUT]]"
243243
// CHK-FPGA-AOCX-SRC: aoc{{.*}} "-o" "[[AOCOUT:.+\.aocx]]" "[[LLVMSPVOUT]]" "-sycl"
@@ -263,7 +263,7 @@
263263
// CHK-FPGA-AOCX-OBJ: clang-offload-bundler{{.*}} "-type=o" {{.*}} "-output=[[HOSTOBJx:.+\.(o|obj)]]" "-output=[[DEVICEOBJ:.+\.(o|obj)]]" "-unbundle"
264264
// CHK-FPGA-AOCX-OBJ: spirv-to-ir-wrapper{{.*}} "[[DEVICEOBJ]]" "-o" "[[IROUTPUT:.+\.bc]]"
265265
// CHK-FPGA-AOCX-OBJ: llvm-link{{.*}} "[[IROUTPUT]]" "-o" "[[LLVMLINKOUT:.+\.bc]]" "--suppress-warnings"
266-
// CHK-FPGA-AOCX-OBJ: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
266+
// CHK-FPGA-AOCX-OBJ: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]
267267
// CHK-FPGA-AOCX-OBJ: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[POSTLINKOUT]]"
268268
// CHK-FPGA-AOCX-OBJ: llvm-spirv{{.*}} "-o" "[[LLVMSPVOUT:.+\.txt]]" {{.*}} "[[TABLEOUT]]"
269269
// CHK-FPGA-AOCX-OBJ: aoc{{.*}} "-o" "[[AOCOUT:.+\.aocx]]" "[[LLVMSPVOUT]]" "-sycl"
@@ -283,15 +283,15 @@
283283
// CHK-FPGA-AOCX-OBJ2: clang-offload-bundler{{.*}} "-type=o" {{.*}} "-output=[[HOSTOBJx:.+\.(o|obj)]]" "-output=[[DEVICEOBJ:.+\.(o|obj)]]" "-output=[[DEVICEOBJ2:.+\.(o|obj)]]" "-unbundle"
284284
// CHK-FPGA-AOCX-OBJ2: spirv-to-ir-wrapper{{.*}} "[[DEVICEOBJ]]" "-o" "[[IROUTPUT:.+\.bc]]"
285285
// CHK-FPGA-AOCX-OBJ2: llvm-link{{.*}} "[[IROUTPUT]]" "-o" "[[LLVMLINKOUT:.+\.bc]]" "--suppress-warnings"
286-
// CHK-FPGA-AOCX-OBJ2: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=native"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]"
286+
// CHK-FPGA-AOCX-OBJ2: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=native"{{.*}} "-o" "[[POSTLINKOUT:.+\.table]]" "[[LLVMLINKOUT]]"
287287
// CHK-FPGA-AOCX-OBJ2: file-table-tform{{.*}} "-o" "[[TABLEOUT:.+\.txt]]" "[[POSTLINKOUT]]"
288288
// CHK-FPGA-AOCX-OBJ2: llvm-spirv{{.*}} "-o" "[[LLVMSPVOUT:.+\.txt]]" {{.*}} "[[TABLEOUT]]"
289289
// CHK-FPGA-AOCX-OBJ2: file-table-tform{{.*}} "-replace=Code,Code" "-o" "[[TFORM_OUT:.+\.table]]" "[[POSTLINKOUT]]" "[[LLVMSPVOUT]]"
290290
// CHK-FPGA-AOCX-OBJ2: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" {{.*}} "-target=spir64" "-kind=sycl" "-batch" "[[TFORM_OUT]]"
291291
// CHK-FPGA-AOCX-OBJ2: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.(o|obj)]]" "[[WRAPOUT]]"
292292
// CHK-FPGA-AOCX-OBJ2: spirv-to-ir-wrapper{{.*}} "[[DEVICEOBJ2]]" "-o" "[[IROUTPUT2:.+\.bc]]"
293293
// CHK-FPGA-AOCX-OBJ2: llvm-link{{.*}} "[[IROUTPUT2]]" "-o" "[[LLVMLINKOUT2:.+\.bc]]" "--suppress-warnings"
294-
// CHK-FPGA-AOCX-OBJ2: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT2:.+\.table]]" "[[LLVMLINKOUT2]]"
294+
// CHK-FPGA-AOCX-OBJ2: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=emulation"{{.*}} "-o" "[[POSTLINKOUT2:.+\.table]]" "[[LLVMLINKOUT2]]"
295295
// CHK-FPGA-AOCX-OBJ2: file-table-tform{{.*}} "-o" "[[TABLEOUT2:.+\.txt]]" "[[POSTLINKOUT2]]"
296296
// CHK-FPGA-AOCX-OBJ2: llvm-spirv{{.*}} "-o" "[[LLVMSPVOUT2:.+\.txt]]" {{.*}} "[[TABLEOUT2]]"
297297
// CHK-FPGA-AOCX-OBJ2: aoc{{.*}} "-o" "[[AOCOUT:.+\.aocx]]" "[[LLVMSPVOUT2]]" "-sycl"

clang/test/Driver/sycl-offload-new-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
6161
// RUN: -Xdevice-post-link -post-link-opt -### %s 2>&1 \
6262
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS_POSTLINK %s
63-
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -post-link-opt"
63+
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -properties -post-link-opt"
6464

6565
// -fsycl-device-only behavior
6666
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \

clang/test/Driver/sycl-post-link-options-win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %clangxx -### --target=x86_64-pc-windows-msvc -fsycl \
44
// RUN: -Xdevice-post-link -O0 %s 2>&1 \
55
// RUN: | FileCheck -check-prefix OPTIONS_POSTLINK_JIT_OLD %s
6-
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
6+
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
77

88
// RUN: %clang -cc1 %s -triple x86_64-pc-windows-msvc -emit-obj -o %t.elf.o
99
// RUN: clang-offload-packager -o %t.out --image=file=%t.elf.o,kind=sycl,triple=spir64

clang/test/Driver/sycl-post-link-options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl -### \
44
// RUN: -Xdevice-post-link -O0 %s 2>&1 \
55
// RUN: | FileCheck -check-prefix OPTIONS_POSTLINK_JIT_OLD %s
6-
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
6+
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
77

88
// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
99
// RUN: clang-offload-packager -o %t.out --image=file=%t.elf.o,kind=sycl,triple=spir64
1010
// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
1111
// RUN: -fembed-offload-object=%t.out
1212
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
1313
// RUN: -sycl-device-library-location=%S/Inputs -sycl-device-libraries=libsycl-crt.new.o \
14-
// RUN: --sycl-post-link-options="-O2 -device-globals -O0" \
14+
// RUN: --sycl-post-link-options="-O2 -device-globals -properties -O0" \
1515
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW %s
16-
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0
16+
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -properties -O0
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===- ComputeModuleRuntimeInfo.h - compute runtime info for module -------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// Functions for computing module properties and symbols for SYCL modules.
9+
//===----------------------------------------------------------------------===//
10+
11+
#pragma once
12+
13+
#include "llvm/ADT/SetVector.h"
14+
#include "llvm/SYCLLowerIR/ModuleSplitter.h"
15+
#include "llvm/Support/PropertySetIO.h"
16+
#include <string>
17+
namespace llvm {
18+
19+
class Function;
20+
class Module;
21+
22+
namespace sycl {
23+
24+
struct GlobalBinImageProps {
25+
bool EmitKernelParamInfo;
26+
bool EmitProgramMetadata;
27+
bool EmitExportedSymbols;
28+
bool EmitImportedSymbols;
29+
bool EmitDeviceGlobalPropSet;
30+
};
31+
bool isModuleUsingAsan(const Module &M);
32+
using PropSetRegTy = llvm::util::PropertySetRegistry;
33+
using EntryPointSet = SetVector<Function *>;
34+
35+
PropSetRegTy computeModuleProperties(const Module &M,
36+
const EntryPointSet &EntryPoints,
37+
const GlobalBinImageProps &GlobProps,
38+
bool SpecConstsMet,
39+
bool IsSpecConstantDefault);
40+
41+
std::string computeModuleSymbolTable(const Module &M,
42+
const EntryPointSet &EntryPoints);
43+
44+
} // namespace sycl
45+
} // namespace llvm

llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class ModuleDesc {
207207

208208
const SYCLDeviceRequirements &getOrComputeDeviceRequirements() const {
209209
if (!Reqs.has_value())
210-
Reqs = computeDeviceRequirements(*this);
210+
Reqs = computeDeviceRequirements(getModule(), entries());
211211
return *Reqs;
212212
}
213213

@@ -306,6 +306,7 @@ struct ModuleSplitterSettings {
306306
Expected<std::vector<SplitModule>>
307307
splitSYCLModule(std::unique_ptr<Module> M, ModuleSplitterSettings Settings);
308308

309+
bool isESIMDFunction(const Function &F);
309310
bool canBeImportedFunction(const Function &F);
310311

311312
} // namespace module_split

llvm/include/llvm/SYCLLowerIR/SYCLDeviceRequirements.h

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

99
#pragma once
1010

11+
#include "llvm/ADT/SetVector.h"
1112
#include "llvm/ADT/SmallString.h"
1213
#include "llvm/ADT/SmallVector.h"
1314
#include "llvm/ADT/StringRef.h"
@@ -19,12 +20,10 @@
1920
#include <vector>
2021

2122
namespace llvm {
22-
23+
class Function;
24+
class Module;
2325
class StringRef;
2426

25-
namespace module_split {
26-
class ModuleDesc;
27-
}
2827
namespace util {
2928
class PropertyValue;
3029
}
@@ -54,6 +53,7 @@ struct SYCLDeviceRequirements {
5453
};
5554

5655
SYCLDeviceRequirements
57-
computeDeviceRequirements(const module_split::ModuleDesc &M);
56+
computeDeviceRequirements(const Module &M,
57+
const SetVector<Function *> &EntryPoints);
5858

5959
} // namespace llvm

llvm/tools/sycl-post-link/SYCLKernelParamOptInfo.h renamed to llvm/include/llvm/SYCLLowerIR/SYCLKernelParamOptInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// attached to kernel functions in a module.
1313
//===----------------------------------------------------------------------===//
1414

15+
#pragma once
16+
1517
#include "llvm/ADT/BitVector.h"
1618
#include "llvm/ADT/DenseMap.h"
1719
#include "llvm/ADT/StringRef.h"

llvm/lib/SYCLLowerIR/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ add_llvm_component_library(LLVMSYCLLowerIR
4747
RecordSYCLAspectNames.cpp
4848
CleanupSYCLMetadata.cpp
4949
CompileTimePropertiesPass.cpp
50+
ComputeModuleRuntimeInfo.cpp
5051
DeviceGlobals.cpp
5152
ESIMD/LowerESIMDVLoadVStore.cpp
5253
ESIMD/LowerESIMDSlmReservation.cpp
@@ -56,8 +57,11 @@ add_llvm_component_library(LLVMSYCLLowerIR
5657
LowerWGScope.cpp
5758
ModuleSplitter.cpp
5859
MutatePrintfAddrspace.cpp
60+
SpecConstants.cpp
5961
SYCLAddOptLevelAttribute.cpp
62+
SYCLDeviceLibReqMask.cpp
6063
SYCLDeviceRequirements.cpp
64+
SYCLKernelParamOptInfo.cpp
6165
SYCLPropagateAspectsUsage.cpp
6266
SYCLPropagateJointMatrixUsage.cpp
6367
SYCLUtils.cpp

0 commit comments

Comments
 (0)