Skip to content

Commit 6a925fd

Browse files
authoredOct 30, 2024
[CIR][CodeGen][NFC] Add some missing guards for unreachable
Reviewers: smeenai Reviewed By: smeenai Pull Request: #1022
1 parent 6a79d2b commit 6a925fd

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed
 

‎clang/include/clang/CIR/MissingFeatures.h

+2
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ struct MissingFeatures {
401401

402402
// This Itanium bit is currently being skipped in cir.
403403
static bool itaniumRecordLayoutBuilderFinishLayout() { return false; }
404+
405+
static bool mustProgress() { return false; }
404406
};
405407

406408
} // namespace cir

‎clang/lib/CIR/CodeGen/CIRGenDecl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@ void CIRGenFunction::buildStaticVarDecl(const VarDecl &D,
679679
else if (D.hasAttr<UsedAttr>())
680680
llvm_unreachable("llvm.compiler.used metadata is NYI");
681681

682+
if (CGM.getCodeGenOpts().KeepPersistentStorageVariables)
683+
llvm_unreachable("NYI");
684+
682685
// From traditional codegen:
683686
// We may have to cast the constant because of the initializer
684687
// mismatch above.

‎clang/lib/CIR/CodeGen/CIRGenFunction.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,16 @@ CIRGenFunction::generateCode(clang::GlobalDecl GD, mlir::cir::FuncOp Fn,
699699
if (Body && isa_and_nonnull<CoroutineBodyStmt>(Body))
700700
llvm::append_range(FnArgs, FD->parameters());
701701

702+
// Ensure that the function adheres to the forward progress guarantee, which
703+
// is required by certain optimizations.
704+
// In C++11 and up, the attribute will be removed if the body contains a
705+
// trivial empty loop.
706+
if (MissingFeatures::mustProgress())
707+
llvm_unreachable("NYI");
708+
702709
// Generate the body of the function.
703710
// TODO: PGO.assignRegionCounters
711+
assert(!MissingFeatures::shouldInstrumentFunction());
704712
if (isa<CXXDestructorDecl>(FD))
705713
buildDestructorBody(Args);
706714
else if (isa<CXXConstructorDecl>(FD))
@@ -751,7 +759,7 @@ mlir::Value CIRGenFunction::createLoad(const VarDecl *VD, const char *Name) {
751759
}
752760

753761
void CIRGenFunction::buildConstructorBody(FunctionArgList &Args) {
754-
// TODO: EmitAsanPrologueOrEpilogue(true);
762+
assert(!MissingFeatures::emitAsanPrologueOrEpilogue());
755763
const auto *Ctor = cast<CXXConstructorDecl>(CurGD.getDecl());
756764
auto CtorType = CurGD.getCtorType();
757765

‎clang/lib/CIR/CodeGen/CIRGenModule.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,8 @@ mlir::cir::FuncOp CIRGenModule::createRuntimeFunction(
24342434
if (AssumeConvergent) {
24352435
llvm_unreachable("NYI");
24362436
}
2437+
if (Local)
2438+
llvm_unreachable("NYI");
24372439

24382440
auto entry = GetOrCreateCIRFunction(Name, Ty, GlobalDecl(),
24392441
/*ForVtable=*/false);

0 commit comments

Comments
 (0)