Skip to content

Commit 2a51d32

Browse files
committed
Address review feedback
1 parent 77391e3 commit 2a51d32

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ struct MissingFeatures {
9898
static bool opCallReturn() { return false; }
9999
static bool opCallArgEvaluationOrder() { return false; }
100100
static bool opCallCallConv() { return false; }
101-
static bool opCallNoPrototypeFunc() { return false; }
102101
static bool opCallMustTail() { return false; }
103102
static bool opCallVirtual() { return false; }
104103
static bool opCallInAlloca() { return false; }

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,14 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
582582
cir::FuncOp directFuncOp;
583583
if (auto fnOp = dyn_cast<cir::FuncOp>(calleePtr)) {
584584
directFuncOp = fnOp;
585-
} else if (auto getGlobalOp = dyn_cast<cir::GetGlobalOp>(calleePtr)) {
585+
} else if (auto getGlobalOp = mlir::dyn_cast<cir::GetGlobalOp>(calleePtr)) {
586586
// FIXME(cir): This peephole optimization avoids indirect calls for
587587
// builtins. This should be fixed in the builtin declaration instead by
588588
// not emitting an unecessary get_global in the first place.
589589
// However, this is also used for no-prototype functions.
590590
mlir::Operation *globalOp = cgm.getGlobalValue(getGlobalOp.getName());
591591
assert(globalOp && "undefined global function");
592-
directFuncOp = llvm::dyn_cast<cir::FuncOp>(globalOp);
593-
assert(directFuncOp && "operation is not a function");
592+
directFuncOp = mlir::cast<cir::FuncOp>(globalOp);
594593
} else {
595594
[[maybe_unused]] mlir::ValueTypeRange<mlir::ResultRange> resultTypes =
596595
calleePtr->getResultTypes();

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ RValue CIRGenFunction::emitCall(clang::QualType calleeTy,
13241324

13251325
mlir::Operation *fn = callee.getFunctionPointer();
13261326
mlir::Value addr;
1327-
if (auto funcOp = llvm::dyn_cast<cir::FuncOp>(fn)) {
1327+
if (auto funcOp = mlir::dyn_cast<cir::FuncOp>(fn)) {
13281328
addr = builder.create<cir::GetGlobalOp>(
13291329
getLoc(e->getSourceRange()),
13301330
cir::PointerType::get(funcOp.getFunctionType()), funcOp.getSymName());
@@ -1336,7 +1336,6 @@ RValue CIRGenFunction::emitCall(clang::QualType calleeTy,
13361336
callee.setFunctionPointer(fn);
13371337
}
13381338

1339-
assert(!cir::MissingFeatures::opCallNoPrototypeFunc());
13401339
assert(!cir::MissingFeatures::opCallFnInfoOpts());
13411340
assert(!cir::MissingFeatures::hip());
13421341
assert(!cir::MissingFeatures::opCallMustTail());

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ void CIRGenModule::replaceUsesOfNonProtoTypeWithRealFunction(
11271127
"replaceUsesOfNonProtoTypeWithRealFunction: Attribute forwarding");
11281128

11291129
// Mark new function as originated from a no-proto declaration.
1130-
newFn.setNoProtoAttr(oldFn.getNoProtoAttr());
1130+
newFn.setNoProto(oldFn.getNoProto());
11311131

11321132
// Iterate through all calls of the no-proto function.
11331133
std::optional<mlir::SymbolTable::UseRange> symUses =
@@ -1746,8 +1746,7 @@ cir::FuncOp CIRGenModule::getOrCreateCIRFunction(
17461746
// Lookup the entry, lazily creating it if necessary.
17471747
mlir::Operation *entry = getGlobalValue(mangledName);
17481748
if (entry) {
1749-
if (!isa<cir::FuncOp>(entry))
1750-
errorNYI(d->getSourceRange(), "getOrCreateCIRFunction: non-FuncOp");
1749+
assert(mlir::isa<cir::FuncOp>(entry));
17511750

17521751
assert(!cir::MissingFeatures::weakRefReference());
17531752

@@ -1794,10 +1793,6 @@ cir::FuncOp CIRGenModule::getOrCreateCIRFunction(
17941793
// Fetch a generic symbol-defining operation and its uses.
17951794
auto symbolOp = mlir::cast<mlir::SymbolOpInterface>(entry);
17961795

1797-
// TODO(cir): When can this symbol be something other than a function?
1798-
if (!isa<cir::FuncOp>(entry))
1799-
errorNYI(d->getSourceRange(), "getOrCreateCIRFunction: non-FuncOp");
1800-
18011796
// This might be an implementation of a function without a prototype, in
18021797
// which case, try to do special replacement of calls which match the new
18031798
// prototype. The really key thing here is that we also potentially drop
@@ -1889,7 +1884,7 @@ CIRGenModule::createCIRFunction(mlir::Location loc, StringRef name,
18891884
assert(!cir::MissingFeatures::opFuncAstDeclAttr());
18901885

18911886
if (funcDecl && !funcDecl->hasPrototype())
1892-
func.setNoProtoAttr(builder.getUnitAttr());
1887+
func.setNoProto(true);
18931888

18941889
assert(func.isDeclaration() && "expected empty body");
18951890

0 commit comments

Comments
 (0)