Skip to content

Commit d29970f

Browse files
committed
Allow -split=auto together with -ir-output-only
1 parent f7d02db commit d29970f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,22 +291,26 @@ enum KernelMapEntryScope {
291291
Scope_Global // single entry in the map for all kernels
292292
};
293293

294-
static KernelMapEntryScope selectDeviceCodeSplitModeAutomatically(Module &M) {
294+
static KernelMapEntryScope selectDeviceCodeSplitScopeAutomatically(Module &M) {
295295
// Here we can employ various heuristics to decide which way to split kernels
296296
// is the best in each particular situation.
297297
// At the moment, we assume that per-kernel split is the best way of splitting
298298
// device code and it can be always selected unless there are functions marked
299299
// with [[intel::device_indirectly_callable]] attribute, because it instructs
300300
// us to make this function available to the whole program as it was compiled
301301
// as a single module.
302-
bool HasDeviceIndirectlyCallable = false;
302+
if (IROutputOnly) {
303+
// We allow enabling auto split mode even in presence of -ir-output-only
304+
// flag, but in this case we are limited by it so we can't do any split at
305+
// all.
306+
return Scope_Global;
307+
}
308+
303309
for (auto &F : M.functions()) {
304310
if (F.hasFnAttribute("referenced-indirectly"))
305-
HasDeviceIndirectlyCallable = true;
311+
return Scope_Global;
306312
}
307313

308-
if (HasDeviceIndirectlyCallable)
309-
return Scope_Global;
310314
return Scope_PerModule;
311315
}
312316

@@ -645,9 +649,9 @@ int main(int argc, char **argv) {
645649
errs() << "no actions specified; try --help for usage info\n";
646650
return 1;
647651
}
648-
if (IROutputOnly && DoSplit) {
649-
errs() << "error: -" << SplitMode.ArgStr << " can't be used with -"
650-
<< IROutputOnly.ArgStr << "\n";
652+
if (IROutputOnly && (DoSplit && SplitMode != SPLIT_AUTO)) {
653+
errs() << "error: -" << SplitMode.ArgStr << "=" << SplitMode.ValueStr
654+
<< " can't be used with -" << IROutputOnly.ArgStr << "\n";
651655
return 1;
652656
}
653657
if (IROutputOnly && DoSymGen) {
@@ -679,7 +683,7 @@ int main(int argc, char **argv) {
679683
KernelMapEntryScope Scope = Scope_Global;
680684
if (DoSplit) {
681685
if (SplitMode == SPLIT_AUTO)
682-
Scope = selectDeviceCodeSplitModeAutomatically(*MPtr);
686+
Scope = selectDeviceCodeSplitScopeAutomatically(*MPtr);
683687
else
684688
Scope =
685689
SplitMode == SPLIT_PER_KERNEL ? Scope_PerKernel : Scope_PerModule;

0 commit comments

Comments
 (0)