Skip to content

Commit 383072c

Browse files
committed
* Update OpenACC test
* Failed function definition will not lead to FuncOp being erased * Try to emit statements after a failure in a compound statement
1 parent 020184b commit 383072c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn,
558558
emitImplicitAssignmentOperatorBody(args);
559559
} else if (body) {
560560
if (mlir::failed(emitFunctionBody(body))) {
561-
fn.erase();
562561
return nullptr;
563562
}
564563
} else {

clang/lib/CIR/CodeGen/CIRGenStmt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ using namespace cir;
2727

2828
mlir::LogicalResult CIRGenFunction::emitCompoundStmtWithoutScope(
2929
const CompoundStmt &s, Address *lastValue, AggValueSlot slot) {
30+
mlir::LogicalResult result = mlir::success();
3031
const Stmt *exprResult = s.getStmtExprResult();
3132
assert((!lastValue || (lastValue && exprResult)) &&
3233
"If lastValue is not null then the CompoundStmt must have a "
3334
"StmtExprResult");
3435

35-
for (Stmt *curStmt : s.body()) {
36+
for (const Stmt *curStmt : s.body()) {
3637
// We have to special case labels here. They are statements, but when put
3738
// at the end of a statement expression, they yield the value of their
3839
// subexpression. Handle this by walking through all labels we encounter,
@@ -66,11 +67,10 @@ mlir::LogicalResult CIRGenFunction::emitCompoundStmtWithoutScope(
6667
}
6768
} else {
6869
if (emitStmt(curStmt, /*useCurrentScope=*/false).failed())
69-
return mlir::failure();
70+
result = mlir::failure();
7071
}
7172
}
72-
73-
return mlir::success();
73+
return result;
7474
}
7575

7676
mlir::LogicalResult CIRGenFunction::emitCompoundStmt(const CompoundStmt &s,

clang/test/CIR/CodeGenOpenACC/openacc-not-implemented.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
void HelloWorld(int *A, int *B, int *C, int N) {
44

5-
// expected-error@+2{{ClangIR code gen Not Yet Implemented: OpenACC Atomic Construct}}
6-
// expected-error@+1{{ClangIR code gen Not Yet Implemented: emitCompoundStmtWithoutScope: OpenACCAtomicConstruct}}
5+
// expected-error@+1{{ClangIR code gen Not Yet Implemented: OpenACC Atomic Construct}}
76
#pragma acc atomic
87
N = N + 1;
98

0 commit comments

Comments
 (0)