Skip to content

Revert "[SYCL] Generate imported symbol files in sycl-post-link" #14183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10702,7 +10702,6 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
// add options unconditionally
addArgs(PostLinkArgs, TCArgs, {"-symbols"});
addArgs(PostLinkArgs, TCArgs, {"-emit-exported-symbols"});
addArgs(PostLinkArgs, TCArgs, {"-emit-imported-symbols"});
if (SplitEsimd)
addArgs(PostLinkArgs, TCArgs, {"-split-esimd"});
addArgs(PostLinkArgs, TCArgs, {"-lower-esimd"});
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-device-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
// RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_NO_DEVICE_LIB
// SYCL_LLVM_LINK_NO_DEVICE_LIB: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
// SYCL_LLVM_LINK_NO_DEVICE_LIB-NOT: llvm-link{{.*}} "-only-needed"
// SYCL_LLVM_LINK_NO_DEVICE_LIB: sycl-post-link{{.*}} "-symbols" "-emit-exported-symbols" "-emit-imported-symbols"{{.*}} "-o" "{{.*}}.table" "{{.*}}.bc"
// SYCL_LLVM_LINK_NO_DEVICE_LIB: sycl-post-link{{.*}} "-symbols" "-emit-exported-symbols"{{.*}} "-o" "{{.*}}.table" "{{.*}}.bc"

/// ###########################################################################
/// test llvm-link behavior for special user input whose filename resembles SYCL device library
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload-new-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
// RUN: -Xdevice-post-link -post-link-opt -### %s 2>&1 \
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS_POSTLINK %s
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-post-link-opt -O2 -device-globals -spec-const=native -split=auto -emit-only-kernels-as-entry-points -symbols -emit-exported-symbols -emit-imported-symbols -lower-esimd"
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-post-link-opt -O2 -device-globals -spec-const=native -split=auto -emit-only-kernels-as-entry-points -symbols -emit-exported-symbols -lower-esimd"

// -fsycl-device-only behavior
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/Support/PropertySetIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class PropertySetRegistry {
static constexpr char SYCL_MISC_PROP[] = "SYCL/misc properties";
static constexpr char SYCL_ASSERT_USED[] = "SYCL/assert used";
static constexpr char SYCL_EXPORTED_SYMBOLS[] = "SYCL/exported symbols";
static constexpr char SYCL_IMPORTED_SYMBOLS[] = "SYCL/imported symbols";
static constexpr char SYCL_DEVICE_GLOBALS[] = "SYCL/device globals";
static constexpr char SYCL_DEVICE_REQUIREMENTS[] = "SYCL/device requirements";
static constexpr char SYCL_HOST_PIPES[] = "SYCL/host pipes";
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Support/PropertySetIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ constexpr char PropertySetRegistry::SYCL_PROGRAM_METADATA[];
constexpr char PropertySetRegistry::SYCL_MISC_PROP[];
constexpr char PropertySetRegistry::SYCL_ASSERT_USED[];
constexpr char PropertySetRegistry::SYCL_EXPORTED_SYMBOLS[];
constexpr char PropertySetRegistry::SYCL_IMPORTED_SYMBOLS[];
constexpr char PropertySetRegistry::SYCL_DEVICE_GLOBALS[];
constexpr char PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS[];
constexpr char PropertySetRegistry::SYCL_HOST_PIPES[];
Expand Down
113 changes: 0 additions & 113 deletions llvm/test/tools/sycl-post-link/emit_imported_symbols.ll

This file was deleted.

51 changes: 4 additions & 47 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/GenXIntrinsics/GenXSPIRVWriterAdaptor.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/LLVMContext.h"
Expand Down Expand Up @@ -229,10 +228,6 @@ cl::opt<bool> EmitExportedSymbols{"emit-exported-symbols",
cl::desc("emit exported symbols"),
cl::cat(PostLinkCat)};

cl::opt<bool> EmitImportedSymbols{"emit-imported-symbols",
cl::desc("emit imported symbols"),
cl::cat(PostLinkCat)};

cl::opt<bool> EmitOnlyKernelsAsEntryPoints{
"emit-only-kernels-as-entry-points",
cl::desc("Consider only sycl_kernel functions as entry points for "
Expand All @@ -255,7 +250,6 @@ struct GlobalBinImageProps {
bool EmitKernelParamInfo;
bool EmitProgramMetadata;
bool EmitExportedSymbols;
bool EmitImportedSymbols;
bool EmitDeviceGlobalPropSet;
};

Expand Down Expand Up @@ -417,25 +411,6 @@ std::string saveModuleIR(Module &M, int I, StringRef Suff) {
return OutFilename;
}

bool isImportedFunction(const Function &F) {
if (!F.isDeclaration() || F.isIntrinsic() ||
!llvm::sycl::utils::isSYCLExternalFunction(&F))
return false;

// StripDeadPrototypes is called during module splitting
// cleanup. At this point all function decls should have uses.
assert(!F.use_empty() && "Function F has no uses");

bool ReturnValue = true;
if (char *NameStr = itaniumDemangle(F.getName())) {
StringRef DemangledName(NameStr);
if (DemangledName.starts_with("__"))
ReturnValue = false;
free(NameStr);
}
return ReturnValue;
}

std::string saveModuleProperties(module_split::ModuleDesc &MD,
const GlobalBinImageProps &GlobProps, int I,
StringRef Suff) {
Expand Down Expand Up @@ -499,21 +474,10 @@ std::string saveModuleProperties(module_split::ModuleDesc &MD,
// so they won't make it into the export list. Should the check be
// F->getCallingConv() != CallingConv::SPIR_KERNEL?
if (F->getCallingConv() == CallingConv::SPIR_FUNC) {
PropSet.add(PropSetRegTy::SYCL_EXPORTED_SYMBOLS, F->getName(),
/*PropVal=*/true);
PropSet.add(PropSetRegTy::SYCL_EXPORTED_SYMBOLS, F->getName(), true);
}
}
}

if (GlobProps.EmitImportedSymbols) {
// record imported functions in the property set
for (const auto &F : M) {
if (isImportedFunction(F))
PropSet.add(PropSetRegTy::SYCL_IMPORTED_SYMBOLS, F.getName(),
/*PropVal=*/true);
}
}

// Metadata names may be composite so we keep them alive until the
// properties have been written.
SmallVector<std::string, 4> MetadataNames;
Expand Down Expand Up @@ -766,8 +730,7 @@ IrPropSymFilenameTriple saveModule(module_split::ModuleDesc &MD, int I,
Res.Ir = saveModuleIR(MD.getModule(), I, Suffix);
}
GlobalBinImageProps Props = {EmitKernelParamInfo, EmitProgramMetadata,
EmitExportedSymbols, EmitImportedSymbols,
DeviceGlobals};
EmitExportedSymbols, DeviceGlobals};
Res.Prop = saveModuleProperties(MD, Props, I, Suffix);

if (DoSymGen) {
Expand Down Expand Up @@ -1286,14 +1249,13 @@ int main(int argc, char **argv) {
bool DoParamInfo = EmitKernelParamInfo.getNumOccurrences() > 0;
bool DoProgMetadata = EmitProgramMetadata.getNumOccurrences() > 0;
bool DoExportedSyms = EmitExportedSymbols.getNumOccurrences() > 0;
bool DoImportedSyms = EmitImportedSymbols.getNumOccurrences() > 0;
bool DoDeviceGlobals = DeviceGlobals.getNumOccurrences() > 0;
bool DoGenerateDeviceImageWithDefaulValues =
GenerateDeviceImageWithDefaultSpecConsts.getNumOccurrences() > 0;

if (!DoSplit && !DoSpecConst && !DoSymGen && !DoParamInfo &&
!DoProgMetadata && !DoSplitEsimd && !DoExportedSyms && !DoImportedSyms &&
!DoDeviceGlobals && !DoLowerEsimd) {
!DoProgMetadata && !DoSplitEsimd && !DoExportedSyms && !DoDeviceGlobals &&
!DoLowerEsimd) {
errs() << "no actions specified; try --help for usage info\n";
return 1;
}
Expand Down Expand Up @@ -1327,11 +1289,6 @@ int main(int argc, char **argv) {
<< " -" << IROutputOnly.ArgStr << "\n";
return 1;
}
if (IROutputOnly && DoImportedSyms) {
errs() << "error: -" << EmitImportedSymbols.ArgStr << " can't be used with"
<< " -" << IROutputOnly.ArgStr << "\n";
return 1;
}
if (IROutputOnly && DoGenerateDeviceImageWithDefaulValues) {
errs() << "error: -" << GenerateDeviceImageWithDefaultSpecConsts.ArgStr
<< " can't be used with -" << IROutputOnly.ArgStr << "\n";
Expand Down
Loading