Skip to content

Commit df52d2f

Browse files
committed
Address review feedback
1 parent b256a40 commit df52d2f

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void CIRGenFunction::startFunction(GlobalDecl gd, QualType returnType,
295295
mlir::Value addrVal =
296296
emitAlloca(cast<NamedDecl>(paramVar)->getName(),
297297
convertType(paramVar->getType()), paramLoc, alignment,
298-
/*insertIntoFnEntryBlock=*/false);
298+
/*insertIntoFnEntryBlock=*/true);
299299

300300
declare(addrVal, paramVar, paramVar->getType(), paramLoc, alignment,
301301
/*isParam=*/true);

clang/test/CIR/CodeGen/loop.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,51 @@ void l2() {
141141
// OGCG: [[FOR_COND]]:
142142
// OGCG: store i32 0, ptr %[[I]], align 4
143143
// OGCG: br label %[[FOR_COND]]
144+
145+
// This is the same as l2 but without a compound statement for the body.
146+
void l3() {
147+
for (;;)
148+
int i = 0;
149+
}
150+
151+
// CIR: cir.func @l3
152+
// CIR-NEXT: cir.scope {
153+
// CIR-NEXT: %[[I:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
154+
// CIR-NEXT: cir.for : cond {
155+
// CIR-NEXT: %[[TRUE:.*]] = cir.const #true
156+
// CIR-NEXT: cir.condition(%[[TRUE]])
157+
// CIR-NEXT: } body {
158+
// CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i
159+
// CIR-NEXT: cir.store %[[ZERO]], %[[I]] : !s32i, !cir.ptr<!s32i>
160+
// CIR-NEXT: cir.yield
161+
// CIR-NEXT: } step {
162+
// CIR-NEXT: cir.yield
163+
// CIR-NEXT: }
164+
// CIR-NEXT: }
165+
// CIR-NEXT: cir.return
166+
// CIR-NEXT: }
167+
168+
// LLVM: define void @l3()
169+
// LLVM: %[[I:.*]] = alloca i32, i64 1, align 4
170+
// LLVM: br label %[[LABEL1:.*]]
171+
// LLVM: [[LABEL1]]:
172+
// LLVM: br label %[[LABEL2:.*]]
173+
// LLVM: [[LABEL2]]:
174+
// LLVM: br i1 true, label %[[LABEL3:.*]], label %[[LABEL5:.*]]
175+
// LLVM: [[LABEL3]]:
176+
// LLVM: store i32 0, ptr %[[I]], align 4
177+
// LLVM: br label %[[LABEL4:.*]]
178+
// LLVM: [[LABEL4]]:
179+
// LLVM: br label %[[LABEL2]]
180+
// LLVM: [[LABEL5]]:
181+
// LLVM: br label %[[LABEL6:.*]]
182+
// LLVM: [[LABEL6]]:
183+
// LLVM: ret void
184+
185+
// OGCG: define{{.*}} void @_Z2l3v()
186+
// OGCG: entry:
187+
// OGCG: %[[I:.*]] = alloca i32, align 4
188+
// OGCG: br label %[[FOR_COND:.*]]
189+
// OGCG: [[FOR_COND]]:
190+
// OGCG: store i32 0, ptr %[[I]], align 4
191+
// OGCG: br label %[[FOR_COND]]

0 commit comments

Comments
 (0)