Skip to content

Commit 1961fd2

Browse files
committed
Address review feedback
1 parent 6cdebf4 commit 1961fd2

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,7 @@ def CIR_ReturnAddrOp : CIR_FuncAddrBuiltinOp<"return_address"> {
22302230
Represents a call to builtin function ` __builtin_return_address` in CIR.
22312231
This builtin function returns the return address of the current function,
22322232
or of one of its callers.
2233+
22332234
The `level` argument is number of frames to scan up the call stack.
22342235
For instance, value of 0 yields the return address of the current function,
22352236
value of 1 yields the return address of the caller of the current function,

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
315315
case Builtin::BI__builtin_return_address:
316316
case Builtin::BI__builtin_frame_address: {
317317
mlir::Location loc = getLoc(e->getExprLoc());
318-
mlir::Attribute levelAttr = ConstantEmitter(*this).emitAbstract(
319-
e->getArg(0), e->getArg(0)->getType());
320-
uint64_t level = mlir::cast<cir::IntAttr>(levelAttr).getUInt();
318+
llvm::APSInt level = e->getArg(0)->EvaluateKnownConstInt(getContext());
321319
if (builtinID == Builtin::BI__builtin_return_address) {
322-
return RValue::get(cir::ReturnAddrOp::create(builder,
323-
loc, builder.getUInt32(level, loc)));
320+
return RValue::get(cir::ReturnAddrOp::create(
321+
builder, loc,
322+
builder.getConstAPInt(loc, builder.getUInt32Ty(), level)));
324323
}
325-
return RValue::get(
326-
cir::FrameAddrOp::create(builder, loc, builder.getUInt32(level, loc)));
324+
return RValue::get(cir::FrameAddrOp::create(
325+
builder, loc,
326+
builder.getConstAPInt(loc, builder.getUInt32Ty(), level)));
327327
}
328328

329329
case Builtin::BI__builtin_trap:

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ createCallLLVMIntrinsicOp(mlir::ConversionPatternRewriter &rewriter,
273273
mlir::Type resultTy, mlir::ValueRange operands) {
274274
auto intrinsicNameAttr =
275275
mlir::StringAttr::get(rewriter.getContext(), intrinsicName);
276-
return mlir::LLVM::CallIntrinsicOp::create(rewriter,
277-
loc, resultTy, intrinsicNameAttr, operands);
276+
return mlir::LLVM::CallIntrinsicOp::create(rewriter, loc, resultTy,
277+
intrinsicNameAttr, operands);
278278
}
279279

280280
static mlir::LLVM::CallIntrinsicOp replaceOpWithCallLLVMIntrinsicOp(

0 commit comments

Comments
 (0)