[clang] [CIR] Upstream basic alloca and load support (PR #128792)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 10:23:15 PST 2025


================
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This contains code to emit Decl nodes as CIR code.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenFunction.h"
+#include "clang/AST/Expr.h"
+#include "clang/CIR/MissingFeatures.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+/// Emit code and set up symbol table for a variable declaration with auto,
+/// register, or no storage class specifier. These turn into simple stack
+/// objects, globals depending on target.
+void CIRGenFunction::emitAutoVarDecl(const VarDecl &d) {
+  QualType ty = d.getType();
+  assert(ty.getAddressSpace() == LangAS::Default);
----------------
andykaylor wrote:

Sort of? The assertion in the incubator asserts that the address space is default or private or OpenCL private. An awful lot of variations go through this path in the eventual implementation. I've ended up with something that is a bit inconsistent in terms of how it's handling `errorNYI `versus `MissingFeatures` versus just leaving things out.

Has there been a discussion on this previously? The incubator uses a lot of `llvm_unreachable("NYI")` but the upstreaming seems to be a mix of `errorNYI` and silently ignoring things. I think the goal should be to leave markers that make it easiest to find the point where new code should be inserted, which for me would mean `llvm_unreachable("NYI")` but there is so much that is NYI at this point that the code would be a very ugly mess.

https://github.com/llvm/llvm-project/pull/128792


More information about the cfe-commits mailing list