aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorMircea Trofin <mtrofin@google.com>2020-01-15 13:33:58 -0800
committerMircea Trofin <mtrofin@google.com>2020-01-15 13:34:20 -0800
commit5466597fee379b44f643cee0e0632fdef8fb6b21 (patch)
tree3f1704c13dc46084ad012ab788efa56416ef7eeb /llvm/lib/Transforms/Utils/InlineFunction.cpp
parentfa26a37d36991dd19276c2112ae03e962debe0e4 (diff)
downloadllvm-5466597fee379b44f643cee0e0632fdef8fb6b21.zip
llvm-5466597fee379b44f643cee0e0632fdef8fb6b21.tar.gz
llvm-5466597fee379b44f643cee0e0632fdef8fb6b21.tar.bz2
[NFC] Refactor InlineResult for readability
Summary: InlineResult is used both in APIs assessing whether a call site is inlinable (e.g. llvm::isInlineViable) as well as in the function inlining utility (llvm::InlineFunction). It means slightly different things (can/should inlining happen, vs did it happen), and the implicit casting may introduce ambiguity (casting from 'false' in InlineFunction will default a message about hight costs, which is incorrect here). The change renames the type to a more generic name, and disables implicit constructors. Reviewers: eraman, davidxl Reviewed By: davidxl Subscribers: kerbowa, arsenm, jvesely, nhaehnle, eraman, hiraditya, haicheng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72744
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 59eb286..9e991ec 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1539,7 +1539,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// FIXME: we don't inline callbr yet.
if (isa<CallBrInst>(TheCall))
- return false;
+ return InlineResult::failure("We don't inline callbr yet.");
// If IFI has any state in it, zap it before we fill it in.
IFI.reset();
@@ -1547,7 +1547,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
Function *CalledFunc = CS.getCalledFunction();
if (!CalledFunc || // Can't inline external function or indirect
CalledFunc->isDeclaration()) // call!
- return "external or indirect";
+ return InlineResult::failure("external or indirect");
// The inliner does not know how to inline through calls with operand bundles
// in general ...
@@ -1561,7 +1561,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
if (Tag == LLVMContext::OB_funclet)
continue;
- return "unsupported operand bundle";
+ return InlineResult::failure("unsupported operand bundle");
}
}
@@ -1580,7 +1580,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
if (!Caller->hasGC())
Caller->setGC(CalledFunc->getGC());
else if (CalledFunc->getGC() != Caller->getGC())
- return "incompatible GC";
+ return InlineResult::failure("incompatible GC");
}
// Get the personality function from the callee if it contains a landing pad.
@@ -1604,7 +1604,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// TODO: This isn't 100% true. Some personality functions are proper
// supersets of others and can be used in place of the other.
else if (CalledPersonality != CallerPersonality)
- return "incompatible personality";
+ return InlineResult::failure("incompatible personality");
}
// We need to figure out which funclet the callsite was in so that we may
@@ -1629,7 +1629,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// for catchpads.
for (const BasicBlock &CalledBB : *CalledFunc) {
if (isa<CatchSwitchInst>(CalledBB.getFirstNonPHI()))
- return "catch in cleanup funclet";
+ return InlineResult::failure("catch in cleanup funclet");
}
}
} else if (isAsynchronousEHPersonality(Personality)) {
@@ -1637,7 +1637,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// funclet in the callee.
for (const BasicBlock &CalledBB : *CalledFunc) {
if (CalledBB.isEHPad())
- return "SEH in cleanup funclet";
+ return InlineResult::failure("SEH in cleanup funclet");
}
}
}
@@ -2247,7 +2247,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
Returns[0]->eraseFromParent();
// We are now done with the inlining.
- return true;
+ return InlineResult::success();
}
// Otherwise, we have the normal case, of more than one block to inline or
@@ -2409,5 +2409,5 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
}
}
- return true;
+ return InlineResult::success();
}