[clang] [CIR] Upstream basic alloca and load support (PR #128792)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 15:07:30 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 1b39328d7440aa7a94af4083257ef1c2f9394887 1ffe43b0ca298df1e35f692d98401579f32d528d --extensions h,cpp -- clang/lib/CIR/CodeGen/Address.h clang/lib/CIR/CodeGen/CIRGenDecl.cpp clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/CodeGen/CIRGenValue.h clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp clang/test/CIR/CodeGen/basic.cpp clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp clang/lib/CIR/CodeGen/CIRGenFunction.cpp clang/lib/CIR/CodeGen/CIRGenFunction.h clang/lib/CIR/CodeGen/CIRGenModule.h clang/lib/CIR/CodeGen/CIRGenStmt.cpp clang/lib/CIR/Dialect/IR/CIRDialect.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
index 444083b764..e44cad559d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
@@ -45,7 +45,7 @@ void CIRGenFunction::emitAutoVarAlloca(const VarDecl &d) {
// Create the temp alloca and declare variable using it.
address = createTempAlloca(allocaTy, alignment, loc, d.getName());
declare(address, &d, ty, getLoc(d.getSourceRange()), alignment);
-
+
setAddrOfLocalVar(&d, address);
}
@@ -72,7 +72,6 @@ void CIRGenFunction::emitAutoVarCleanups(const clang::VarDecl &d) {
cgm.errorNYI(d.getSourceRange(), "emitAutoVarCleanups: CleanupAttr");
}
-
/// 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.
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 2c09db9610..ccc3e20875 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -38,8 +38,8 @@ mlir::Value CIRGenFunction::emitLoadOfScalar(LValue lvalue,
if (mlir::isa<cir::VoidType>(eltTy))
cgm.errorNYI(loc, "emitLoadOfScalar: void type");
- mlir::Value loadOp = builder.CIRBaseBuilderTy::createLoad(getLoc(loc), ptr,
- false /*isVolatile*/);
+ mlir::Value loadOp = builder.CIRBaseBuilderTy::createLoad(
+ getLoc(loc), ptr, false /*isVolatile*/);
return loadOp;
}
@@ -98,7 +98,8 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) {
}
mlir::Value CIRGenFunction::emitAlloca(StringRef name, mlir::Type ty,
- mlir::Location loc, CharUnits alignment) {
+ mlir::Location loc,
+ CharUnits alignment) {
mlir::Block *entryBlock = getCurFunctionEntryBlock();
// CIR uses its own alloca address space rather than follow the target data
@@ -122,7 +123,8 @@ mlir::Value CIRGenFunction::emitAlloca(StringRef name, mlir::Type ty,
/// This creates an alloca and inserts it at the current insertion point of the
/// builder.
Address CIRGenFunction::createTempAlloca(mlir::Type ty, CharUnits align,
- mlir::Location loc, const Twine &name) {
+ mlir::Location loc,
+ const Twine &name) {
mlir::Value alloca = emitAlloca(name.str(), ty, loc, align);
return Address(alloca, ty, align);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/128792
More information about the cfe-commits
mailing list