Skip to content

Commit 6b6501f

Browse files
committed
[clang-offload-deps] Use @llvm.used global for SYCL references
Use @llvm.used global variable for representing a reference for 'sycl' offloading kind. Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent b6374c7 commit 6b6501f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/tools/clang-offload-deps/ClangOffloadDeps.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ int main(int argc, const char **argv) {
104104
// <kind>-<triple>
105105
// where <kind> is host, openmp, hip, sycl or fpga,
106106
// and <triple> is an offload target triple.
107+
SmallVector<StringRef, 8u> Kinds(Targets.size());
107108
SmallVector<StringRef, 8u> Triples(Targets.size());
108109
for (unsigned I = 0; I < Targets.size(); ++I) {
109-
StringRef Kind;
110-
std::tie(Kind, Triples[I]) = StringRef(Targets[I]).split('-');
110+
std::tie(Kinds[I], Triples[I]) = StringRef(Targets[I]).split('-');
111111

112-
bool KindIsValid = StringSwitch<bool>(Kind)
112+
bool KindIsValid = StringSwitch<bool>(Kinds[I])
113113
.Case("host", true)
114114
.Case("openmp", true)
115115
.Case("hip", true)
@@ -124,7 +124,7 @@ int main(int argc, const char **argv) {
124124
raw_svector_ostream Msg(Buf);
125125
Msg << "invalid target '" << Targets[I] << "'";
126126
if (!KindIsValid)
127-
Msg << ", unknown offloading kind '" << Kind << "'";
127+
Msg << ", unknown offloading kind '" << Kinds[I] << "'";
128128
if (!TripleIsValid)
129129
Msg << ", unknown target triple '" << Triples[I] << "'";
130130
reportError(createStringError(errc::invalid_argument, Msg.str()));
@@ -202,11 +202,11 @@ int main(int argc, const char **argv) {
202202
if (!Used.empty()) {
203203
ArrayType *ArrayTy = ArrayType::get(Int8PtrTy, Used.size());
204204

205-
// SPIRV linking is done on LLVM IR inputs, so we can use special
205+
// SYCL/SPIRV linking is done on LLVM IR inputs, so we can use special
206206
// global variable llvm.used to represent a reference to a symbol. But for
207207
// other targets we have to create a real reference since llvm.used may
208208
// not be representable in the object file.
209-
if (Triple(Triples[I]).isSPIR()) {
209+
if (Kinds[I] == "sycl" || Triple(Triples[I]).isSPIR()) {
210210
auto *GV = new GlobalVariable(
211211
Mod, ArrayTy, false, GlobalValue::AppendingLinkage,
212212
ConstantArray::get(ArrayTy, Used), "llvm.used");

0 commit comments

Comments
 (0)