addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias);
}
+ /// Do not optimize this function (-O0).
+ bool optForNone() const { return hasFnAttribute(Attribute::OptimizeNone); }
+
/// Optimize this function for minimum size (-Oz).
bool optForMinSize() const { return hasFnAttribute(Attribute::MinSize); }
break;
}
- if (F->isDeclaration() || F->hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F->isDeclaration() || F->optForNone()) {
// Try to get mod/ref behaviour from function attributes.
if (F->doesNotAccessMemory()) {
// Can't do better than that!
// Don't prove any properties based on the implementation of an optnone
// function. Function attributes were already used as a best approximation
// above.
- if (Node->getFunction()->hasFnAttribute(Attribute::OptimizeNone))
+ if (Node->getFunction()->optForNone())
continue;
for (Instruction &I : instructions(Node->getFunction())) {
return llvm::InlineCost::getNever("conflicting attributes");
// Don't inline this call if the caller has the optnone attribute.
- if (Caller->hasFnAttribute(Attribute::OptimizeNone))
+ if (Caller->optForNone())
return llvm::InlineCost::getNever("optnone attribute");
// Don't inline a function that treats null pointer as valid into a caller
if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(*L)))
return true;
// Check for the OptimizeNone attribute.
- if (F->hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F->optForNone()) {
// FIXME: Report this to dbgs() only once per function.
LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' in function "
<< F->getName() << "\n");
if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(R)))
return true;
- if (F.hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F.optForNone()) {
// Report this only once per function.
if (R.getEntry() == &F.getEntryBlock())
LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName()
FPO |= FrameProcedureOptions::SecurityChecks;
FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedLocalFramePtrReg) << 14U);
FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedParamFramePtrReg) << 16U);
- if (Asm->TM.getOptLevel() != CodeGenOpt::None && !GV.optForSize() &&
- !GV.hasFnAttribute(Attribute::OptimizeNone))
+ if (Asm->TM.getOptLevel() != CodeGenOpt::None &&
+ !GV.optForSize() && !GV.optForNone())
FPO |= FrameProcedureOptions::OptimizedForSpeed;
// FIXME: Set GuardCfg when it is implemented.
CurFn->FrameProcOpts = FPO;
LLVM_DEBUG(dbgs() << "Assign register banks for: " << MF.getName() << '\n');
const Function &F = MF.getFunction();
Mode SaveOptMode = OptMode;
- if (F.hasFnAttribute(Attribute::OptimizeNone))
+ if (F.optForNone())
OptMode = Mode::Fast;
init(MF);
if (!isa<CallInst>(UnsafeStackPtr))
return;
- if(F.hasFnAttribute(Attribute::OptimizeNone))
+ if(F.optForNone())
return;
CallSite CS(UnsafeStackPtr);
if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(F)))
return true;
- if (F.hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F.optForNone()) {
LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function "
<< F.getName() << "\n");
return true;
OptPassGate &Gate = F->getContext().getOptPassGate();
if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(BB)))
return true;
- if (F->hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F->optForNone()) {
// Report this only once per function.
if (&BB == &F->getEntryBlock())
LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName()
// Calculate this function's optimization goal.
unsigned OptimizationGoal;
- if (F.hasFnAttribute(Attribute::OptimizeNone))
+ if (F.optForNone())
// For best debugging illusion, speed and small size sacrificed
OptimizationGoal = 6;
else if (F.optForMinSize())
}
static inline bool isOptNone(const MachineFunction &MF) {
- return MF.getFunction().hasFnAttribute(Attribute::OptimizeNone) ||
+ return MF.getFunction().optForNone() ||
MF.getTarget().getOptLevel() == CodeGenOpt::None;
}
bool HasUnknownCall = false;
for (LazyCallGraph::Node &N : C) {
Function &F = N.getFunction();
- if (F.hasFnAttribute(Attribute::OptimizeNone) ||
- F.hasFnAttribute(Attribute::Naked)) {
+ if (F.optForNone() || F.hasFnAttribute(Attribute::Naked)) {
// Treat any function we're trying not to optimize as if it were an
// indirect call and omit it from the node set used below.
HasUnknownCall = true;
bool ExternalNode = false;
for (CallGraphNode *I : SCC) {
Function *F = I->getFunction();
- if (!F || F->hasFnAttribute(Attribute::OptimizeNone) ||
- F->hasFnAttribute(Attribute::Naked)) {
+ if (!F || F->optForNone() || F->hasFnAttribute(Attribute::Naked)) {
// External node or function we're trying not to optimize - we both avoid
// transform them and avoid leveraging information they provide.
ExternalNode = true;
/// module has profile data), set entry count to 0 to ensure treated as cold.
/// Return true if the function is changed.
static bool markFunctionCold(Function &F, bool UpdateEntryCount = false) {
- assert(!F.hasFnAttribute(Attribute::OptimizeNone) && "Can't mark this cold");
+ assert(!F.optForNone() && "Can't mark this cold");
bool Changed = false;
if (!F.hasFnAttribute(Attribute::Cold)) {
F.addFnAttr(Attribute::Cold);
continue;
// Do not modify `optnone` functions.
- if (F.hasFnAttribute(Attribute::OptimizeNone))
+ if (F.optForNone())
continue;
// Detect inherently cold functions and mark them as such.
for (Function &F : M.functions())
// We only infer things using the prototype and the name; we don't need
// definitions.
- if (F.isDeclaration() && !F.hasFnAttribute((Attribute::OptimizeNone)))
+ if (F.isDeclaration() && !F.optForNone())
Changed |= inferLibFuncAttributes(F, TLI);
return Changed;
LazyCallGraph::Node &N = *CG.lookup(F);
if (CG.lookupSCC(N) != C)
continue;
- if (F.hasFnAttribute(Attribute::OptimizeNone)) {
+ if (F.optForNone()) {
setInlineRemark(Calls[i].first, "optnone attribute");
continue;
}
}
bool Changed = false;
for (auto &F : M) {
- if (F.isDeclaration())
- continue;
- if (F.hasFnAttribute(Attribute::OptimizeNone))
+ if (F.isDeclaration() || F.optForNone())
continue;
std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
WarnMissedTransformationsPass::run(Function &F, FunctionAnalysisManager &AM) {
// Do not warn about not applied transformations if optimizations are
// disabled.
- if (F.hasFnAttribute(Attribute::OptimizeNone))
+ if (F.optForNone())
return PreservedAnalyses::all();
auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F);