1313#include " Address.h"
1414#include " CIRGenFunction.h"
1515#include " CIRGenValue.h"
16+ #include " mlir/IR/BuiltinAttributes.h"
1617#include " clang/AST/Attr.h"
1718#include " clang/AST/CharUnits.h"
1819#include " clang/AST/Decl.h"
@@ -33,11 +34,11 @@ mlir::Value CIRGenFunction::emitLoadOfScalar(LValue lvalue,
3334 Address addr = lvalue.getAddress ();
3435 mlir::Type eltTy = addr.getElementType ();
3536
36- auto ptr = addr.getPointer ();
37+ mlir::Value ptr = addr.getPointer ();
3738 if (mlir::isa<cir::VoidType>(eltTy))
3839 cgm.errorNYI (loc, " emitLoadOfScalar: void type" );
3940
40- auto loadOp = builder.CIRBaseBuilderTy ::createLoad (getLoc (loc), ptr,
41+ mlir::Value loadOp = builder.CIRBaseBuilderTy ::createLoad (getLoc (loc), ptr,
4142 false /* isVolatile*/ );
4243
4344 return loadOp;
@@ -54,6 +55,7 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) {
5455 return RValue::get (emitLoadOfScalar (lv, loc));
5556
5657 cgm.errorNYI (loc, " emitLoadOfLValue" );
58+ return RValue::get (nullptr );
5759}
5860
5961LValue CIRGenFunction::emitDeclRefLValue (const DeclRefExpr *e) {
@@ -92,37 +94,35 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) {
9294 }
9395
9496 cgm.errorNYI (e->getSourceRange (), " emitDeclRefLValue: unhandled decl type" );
97+ return LValue ();
9598}
9699
97100mlir::Value CIRGenFunction::emitAlloca (StringRef name, mlir::Type ty,
98- mlir::Location loc, CharUnits alignment,
99- mlir::Value arraySize) {
101+ mlir::Location loc, CharUnits alignment) {
100102 mlir::Block *entryBlock = getCurFunctionEntryBlock ();
101103
102- // CIR uses its own alloca AS rather than follow the target data layout like
103- // original CodeGen. The data layout awareness should be done in the lowering
104- // pass instead.
104+ // CIR uses its own alloca address space rather than follow the target data
105+ // layout like original CodeGen. The data layout awareness should be done in
106+ // the lowering pass instead.
105107 assert (!cir::MissingFeatures::addressSpace ());
106- auto localVarPtrTy = builder.getPointerTo (ty);
107- auto alignIntAttr = cgm.getSize (alignment);
108+ cir::PointerType localVarPtrTy = builder.getPointerTo (ty);
109+ mlir::IntegerAttr alignIntAttr = cgm.getSize (alignment);
108110
109111 mlir::Value addr;
110112 {
111113 mlir::OpBuilder::InsertionGuard guard (builder);
112114 builder.restoreInsertionPoint (builder.getBestAllocaInsertPoint (entryBlock));
113115 addr = builder.createAlloca (loc, /* addr type*/ localVarPtrTy,
114- /* var type*/ ty, name, alignIntAttr, arraySize );
116+ /* var type*/ ty, name, alignIntAttr);
115117 assert (!cir::MissingFeatures::opAllocaVarDeclContext ());
116118 }
117119 return addr;
118120}
119121
120- // / This creates an alloca and inserts it into the entry block if \p ArraySize
121- // / is nullptr, otherwise inserts it at the current insertion point of the
122+ // / This creates an alloca and inserts it at the current insertion point of the
122123// / builder.
123124Address CIRGenFunction::createTempAlloca (mlir::Type ty, CharUnits align,
124- mlir::Location loc, const Twine &name,
125- mlir::Value arraySize) {
126- mlir::Value alloca = emitAlloca (name.str (), ty, loc, align, arraySize);
125+ mlir::Location loc, const Twine &name) {
126+ mlir::Value alloca = emitAlloca (name.str (), ty, loc, align);
127127 return Address (alloca, ty, align);
128128}
0 commit comments