forked from OSchip/llvm-project
Add a Function::isExternal utility to simplify checks for external functions.
PiperOrigin-RevId: 235746553
This commit is contained in:
parent
cdbfd48471
commit
79944e5eef
|
@ -80,6 +80,9 @@ public:
|
|||
/// Unlink this function from its module and delete it.
|
||||
void erase();
|
||||
|
||||
/// Returns true if this function is external, i.e. it has no body.
|
||||
bool isExternal() const { return empty(); }
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Body Handling
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
|
|
@ -90,7 +90,7 @@ bool FuncVerifier::verify() {
|
|||
fn.getName().c_str());
|
||||
|
||||
// External functions have nothing more to check.
|
||||
if (fn.empty())
|
||||
if (fn.isExternal())
|
||||
return false;
|
||||
|
||||
// Verify the first block has no predecessors.
|
||||
|
|
|
@ -1301,7 +1301,7 @@ void FunctionPrinter::printFunctionSignature() {
|
|||
auto fnType = function->getType();
|
||||
|
||||
// If this is an external function, don't print argument labels.
|
||||
if (function->empty()) {
|
||||
if (function->isExternal()) {
|
||||
interleaveComma(fnType.getInputs(),
|
||||
[&](Type eltType) { printType(eltType); });
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ void ModulePass::anchor() {}
|
|||
PassResult FunctionPass::runOnModule(Module *m) {
|
||||
for (auto &fn : *m) {
|
||||
// All function passes ignore external functions.
|
||||
if (fn.empty())
|
||||
if (fn.isExternal())
|
||||
continue;
|
||||
|
||||
if (runOnFunction(&fn))
|
||||
|
|
|
@ -513,7 +513,7 @@ bool ModuleTranslation::convertFunctions() {
|
|||
// Convert functions.
|
||||
for (const Function &function : mlirModule) {
|
||||
// Ignore external functions.
|
||||
if (function.empty())
|
||||
if (function.isExternal())
|
||||
continue;
|
||||
|
||||
if (convertOneFunction(function))
|
||||
|
|
Loading…
Reference in New Issue