Skip to content
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
8 changes: 4 additions & 4 deletions clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
// ----------------------
//
OpBuilder::InsertPoint getBestAllocaInsertPoint(mlir::Block *block) {
auto lastAlloca =
auto last =
std::find_if(block->rbegin(), block->rend(), [](mlir::Operation &op) {
return mlir::isa<mlir::cir::AllocaOp>(&op);
return mlir::isa<mlir::cir::AllocaOp, mlir::cir::LabelOp>(&op);
});

if (lastAlloca != block->rend())
if (last != block->rend())
return OpBuilder::InsertPoint(block,
++mlir::Block::iterator(&*lastAlloca));
++mlir::Block::iterator(&*last));
return OpBuilder::InsertPoint(block, block->begin());
};

Expand Down
18 changes: 17 additions & 1 deletion clang/test/CIR/CodeGen/goto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,20 @@ void flatLoopWithNoTerminatorInFront(int* ptr) {
// CHECK: ^bb[[#RETURN]]:
// CHECK: cir.return
// CHECK: }
// CHECK:}
// CHECK:}

struct S {};
struct S get();
void bar(struct S);

void foo() {
{
label:
bar(get());
}
}

// NOFLAT: cir.func @_Z3foov()
// NOFLAT: cir.scope {
// NOFLAT: cir.label "label"
// NOFLAT: %0 = cir.alloca !ty_S, !cir.ptr<!ty_S>, ["agg.tmp0"]