Skip to content

Commit 4b0a36d

Browse files
committed
[CIR][CIRGen][NFC] Improve buildAutoVarAlloca skeleton and add hooks for buildVarAnnotations
1 parent 07897b3 commit 4b0a36d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ CIRGenFunction::buildAutoVarAlloca(const VarDecl &D,
3939
assert(
4040
Ty.getAddressSpace() == LangAS::Default ||
4141
(Ty.getAddressSpace() == LangAS::opencl_private && getLangOpts().OpenCL));
42-
assert(!D.hasAttr<AnnotateAttr>() && "not implemented");
4342

4443
auto loc = getLoc(D.getSourceRange());
4544
bool NRVO =
@@ -195,6 +194,16 @@ CIRGenFunction::buildAutoVarAlloca(const VarDecl &D,
195194

196195
emission.Addr = address;
197196
setAddrOfLocalVar(&D, emission.Addr);
197+
198+
// Emit debug info for local var declaration.
199+
assert(!MissingFeatures::generateDebugInfo());
200+
201+
if (D.hasAttr<AnnotateAttr>() && HaveInsertPoint())
202+
buildVarAnnotations(&D, address.emitRawPointer());
203+
204+
// TODO(cir): in LLVM this calls @llvm.lifetime.end.
205+
assert(!MissingFeatures::shouldEmitLifetimeMarkers());
206+
198207
return emission;
199208
}
200209

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1889,3 +1889,10 @@ mlir::Value CIRGenFunction::buildAlignmentAssumption(
18891889
return buildAlignmentAssumption(ptrValue, ty, loc, assumptionLoc, alignment,
18901890
offsetValue);
18911891
}
1892+
1893+
void CIRGenFunction::buildVarAnnotations(const VarDecl *decl, mlir::Value val) {
1894+
assert(decl->hasAttr<AnnotateAttr>() && "no annotate attribute");
1895+
for ([[maybe_unused]] const auto *I : decl->specific_attrs<AnnotateAttr>()) {
1896+
llvm_unreachable("NYI");
1897+
}
1898+
}

clang/lib/CIR/CodeGen/CIRGenFunction.h

+3
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,9 @@ class CIRGenFunction : public CIRGenTypeCache {
11201120

11211121
void buildDecl(const clang::Decl &D);
11221122

1123+
/// Emit local annotations for the local variable V, declared by D.
1124+
void buildVarAnnotations(const VarDecl *decl, mlir::Value val);
1125+
11231126
/// If the specified expression does not fold to a constant, or if it does but
11241127
/// contains a label, return false. If it constant folds return true and set
11251128
/// the boolean result in Result.

0 commit comments

Comments
 (0)