Skip to content

Commit 4c542b6

Browse files
author
Alexander Batashev
committed
Merge remote-tracking branch 'origin/sycl' into private/abatashe/move_int_headers
* origin/sycl: [SYCL] Improve the error mechanism of llvm-no-spir-kernel (intel#1068)
2 parents 8133219 + 2295308 commit 4c542b6

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; UNSUPPORTED: system-windows
2+
3+
; Check the return code
4+
; RUN: llvm-no-spir-kernel %s; \
5+
; RUN: if [ $? = 1 ]; then exit 0; else exit 1; fi
6+
7+
; expected failure
8+
define spir_kernel void @foo() {
9+
bb:
10+
ret void
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
; RUN: not llvm-no-spir-kernel %s
1+
; RUN: not llvm-no-spir-kernel %s 2>&1 | FileCheck %s
22

3-
; expected failure
4-
define spir_kernel void @foo() {
3+
; expected no failures
4+
define void @foo() {
55
bb:
66
ret void
77
}
88

9-
9+
; expected failure
10+
; CHECK: error: Unexpected SPIR kernel occurrence:
11+
; CHECK-SAME: foo2
12+
define spir_kernel void @foo2() {
13+
bb:
14+
ret void
15+
}

llvm/test/tools/llvm-no-spir-kernel/has-spir-kernel2.ll

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; RUN: echo garbage > garbage.ll
2+
; RUN: not llvm-no-spir-kernel garbage.ll

llvm/tools/llvm-no-spir-kernel/llvm-no-spir-kernel.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This utility checks if the input module contains functions that is a spir
10-
// kernel. Return 0 if no, return 1 if yes. Use of an output file is not
11-
// required for a successful check. It is used to allow for proper input and
12-
// output flow within the driver toolchain.
9+
// This utility checks if the input module contains functions that are a SPIR
10+
// kernel.
11+
//
12+
// - Return 0 if the LLVM module is "clean" from SPIR kernels
13+
// - Return 1 upon the first SPIR kernel occurence
14+
//
15+
// Use of an output file is not required for a successful check. It is used
16+
// to allow for proper input and output flow within the driver toolchain.
1317
//
1418
// Usage: llvm-no-spir-kernel input.bc/input.ll -o output.bc/output.ll
1519
//
1620
//===----------------------------------------------------------------------===//
1721

22+
#include "llvm/Demangle/Demangle.h"
1823
#include "llvm/IR/LLVMContext.h"
1924
#include "llvm/IR/Module.h"
2025
#include "llvm/IRReader/IRReader.h"
@@ -44,15 +49,21 @@ int main(int argc, char **argv) {
4449

4550
// Use lazy loading, since we only care about function calling convention
4651
SMDiagnostic Err;
52+
const char *ProgramName = llvm::sys::path::filename(argv[0]).data();
4753
std::unique_ptr<Module> M = getLazyIRFileModule(InputFilename, Err, Context);
4854

4955
if (!M.get()) {
50-
Err.print(argv[0], errs());
56+
Err.print(ProgramName, errs());
5157
return 1;
5258
}
5359

5460
for (auto &F : *M) {
5561
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
62+
std::string SPIRKernelMsg =
63+
"Unexpected SPIR kernel occurrence: " + demangle(F.getName().str());
64+
SMDiagnostic SPIRKernelDiag(InputFilename, SourceMgr::DiagKind::DK_Error,
65+
SPIRKernelMsg);
66+
SPIRKernelDiag.print(ProgramName, errs());
5667
return 1;
5768
}
5869
}

0 commit comments

Comments
 (0)