Skip to content
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

Fail when clang FE returned an error #377

Merged
merged 2 commits into from
Jan 2, 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
4 changes: 4 additions & 0 deletions tools/cgeist/Lib/clang-mlir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6136,6 +6136,10 @@ static bool parseMLIR(const char *Argv0, std::vector<std::string> filenames,
Act.EndSourceFile();
}
}

if (Clang->getDiagnostics().hasErrorOccurred()) {
return false;
}
}
return true;
}
2 changes: 1 addition & 1 deletion tools/cgeist/Test/Verification/freecst.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cgeist %s --function=* -S | FileCheck %s
// RUN: cgeist %s %stdinclude --function=* -S | FileCheck %s

#include <stdlib.h>
struct band {
Expand Down
4 changes: 4 additions & 0 deletions tools/cgeist/Test/Verification/invalid/basic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: cgeist %s --function=* -S
// XFAIL: *

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to instead check for failure with // XFAIL: *

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int main() {
4 changes: 4 additions & 0 deletions tools/cgeist/Test/Verification/invalid/invalid_include.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: cgeist %s --function=* -S
// XFAIL: *

#include "non-existing-header.h"
2 changes: 1 addition & 1 deletion tools/cgeist/Test/Verification/memref-fullrank.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

Expand Down
3 changes: 2 additions & 1 deletion tools/cgeist/Test/Verification/ompParallelNumThreads.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: cgeist %s --function=* -fopenmp -S | FileCheck %s
#include <omp.h>

int omp_get_thread_num();

void test_parallel_num_threads(double* x, int sinc) {
// CHECK: %[[c32:.+]] = arith.constant 32 : i32
Expand Down
4 changes: 2 additions & 2 deletions tools/cgeist/Test/Verification/raiseToAffineUnsignedCmp.c
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,4 +21,4 @@ void matmul(float A[100][200], float B[200][300], float C[100][300]) {
}
}
}

}
4 changes: 2 additions & 2 deletions tools/cgeist/Test/Verification/triple.cu
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 4 additions & 2 deletions tools/cgeist/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading