diff --git a/tools/cgeist/Lib/clang-mlir.cc b/tools/cgeist/Lib/clang-mlir.cc index 36e8af8c7a6d..eaeb377eed94 100644 --- a/tools/cgeist/Lib/clang-mlir.cc +++ b/tools/cgeist/Lib/clang-mlir.cc @@ -6136,6 +6136,10 @@ static bool parseMLIR(const char *Argv0, std::vector filenames, Act.EndSourceFile(); } } + + if (Clang->getDiagnostics().hasErrorOccurred()) { + return false; + } } return true; } diff --git a/tools/cgeist/Test/Verification/freecst.c b/tools/cgeist/Test/Verification/freecst.c index 7bdc3805db3d..c47d42de599c 100755 --- a/tools/cgeist/Test/Verification/freecst.c +++ b/tools/cgeist/Test/Verification/freecst.c @@ -1,4 +1,4 @@ -// RUN: cgeist %s --function=* -S | FileCheck %s +// RUN: cgeist %s %stdinclude --function=* -S | FileCheck %s #include struct band { diff --git a/tools/cgeist/Test/Verification/invalid/basic.cpp b/tools/cgeist/Test/Verification/invalid/basic.cpp new file mode 100644 index 000000000000..a66870704da7 --- /dev/null +++ b/tools/cgeist/Test/Verification/invalid/basic.cpp @@ -0,0 +1,4 @@ +// RUN: cgeist %s --function=* -S +// XFAIL: * + +int main() { diff --git a/tools/cgeist/Test/Verification/invalid/invalid_include.cpp b/tools/cgeist/Test/Verification/invalid/invalid_include.cpp new file mode 100644 index 000000000000..6cb45657dabb --- /dev/null +++ b/tools/cgeist/Test/Verification/invalid/invalid_include.cpp @@ -0,0 +1,4 @@ +// RUN: cgeist %s --function=* -S +// XFAIL: * + +#include "non-existing-header.h" diff --git a/tools/cgeist/Test/Verification/memref-fullrank.c b/tools/cgeist/Test/Verification/memref-fullrank.c index 1984fef540a6..7b5037ed769d 100644 --- a/tools/cgeist/Test/Verification/memref-fullrank.c +++ b/tools/cgeist/Test/Verification/memref-fullrank.c @@ -1,4 +1,4 @@ -// RUN: cgeist %s -S --function=main -memref-fullrank -O0 | FileCheck %s +// RUN: cgeist %s -S %stdinclude --function=main -memref-fullrank -O0 | FileCheck %s #include diff --git a/tools/cgeist/Test/Verification/ompParallelNumThreads.c b/tools/cgeist/Test/Verification/ompParallelNumThreads.c index 608035901910..7b9fb1092d48 100644 --- a/tools/cgeist/Test/Verification/ompParallelNumThreads.c +++ b/tools/cgeist/Test/Verification/ompParallelNumThreads.c @@ -1,5 +1,6 @@ // RUN: cgeist %s --function=* -fopenmp -S | FileCheck %s -#include + +int omp_get_thread_num(); void test_parallel_num_threads(double* x, int sinc) { // CHECK: %[[c32:.+]] = arith.constant 32 : i32 diff --git a/tools/cgeist/Test/Verification/raiseToAffineUnsignedCmp.c b/tools/cgeist/Test/Verification/raiseToAffineUnsignedCmp.c index 643d8f3dec74..1d0e4b9ff9d8 100644 --- a/tools/cgeist/Test/Verification/raiseToAffineUnsignedCmp.c +++ b/tools/cgeist/Test/Verification/raiseToAffineUnsignedCmp.c @@ -1,4 +1,4 @@ -// RUN: cgeist %s --function=matmul --raise-scf-to-affine -S | FileCheck %s +// RUN: cgeist %s %stdinclude --function=matmul --raise-scf-to-affine -S | FileCheck %s void matmul(float A[100][200], float B[200][300], float C[100][300]) { int i, j, k; @@ -21,4 +21,4 @@ void matmul(float A[100][200], float B[200][300], float C[100][300]) { } } } - +} diff --git a/tools/cgeist/Test/Verification/triple.cu b/tools/cgeist/Test/Verification/triple.cu index adc857c59e70..717fcfe46cef 100644 --- a/tools/cgeist/Test/Verification/triple.cu +++ b/tools/cgeist/Test/Verification/triple.cu @@ -1,5 +1,5 @@ -// RUN: cgeist --target aarch64-unknown-linux-gnu %s %stdinclude -S -o - | FileCheck %s -check-prefix=MLIR -// RUN: cgeist --target aarch64-unknown-linux-gnu %s %stdinclude -emit-llvm -S -o - | FileCheck %s -check-prefix=LLVM +// RUN: cgeist --target aarch64-unknown-linux-gnu %s -nocudalib -nocudainc %stdinclude -S -o - | FileCheck %s -check-prefix=MLIR +// RUN: cgeist --target aarch64-unknown-linux-gnu %s -nocudalib -nocudainc %stdinclude -emit-llvm -S -o - | FileCheck %s -check-prefix=LLVM // MLIR: llvm.target_triple = "aarch64-unknown-linux-gnu" // LLVM: target triple = "aarch64-unknown-linux-gnu" diff --git a/tools/cgeist/driver.cc b/tools/cgeist/driver.cc index 4fdd907ddff1..45c92f80bff5 100644 --- a/tools/cgeist/driver.cc +++ b/tools/cgeist/driver.cc @@ -571,8 +571,10 @@ int main(int argc, char **argv) { llvm::DataLayout DL(""); llvm::Triple gpuTriple; llvm::DataLayout gpuDL(""); - parseMLIR(argv[0], files, cfunction, includeDirs, defines, module, triple, DL, - gpuTriple, gpuDL); + if (!parseMLIR(argv[0], files, cfunction, includeDirs, defines, module, + triple, DL, gpuTriple, gpuDL)) { + return 1; + } auto convertGepInBounds = [](llvm::Module &llvmModule) { for (auto &F : llvmModule) {