diff options
author | Devang Patel <dpatel@apple.com> | 2008-09-22 22:32:29 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-09-22 22:32:29 +0000 |
commit | f3ba70861ccf00b1072ae1b6ade3ebe2da6cff40 (patch) | |
tree | 5e1aeee0c7c60ca44ec90d45c700e24a14aa2b89 | |
parent | ef901c57563eb841ac86648d533272776706cb64 (diff) |
Add hasNote() to check note associated with a function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56477 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Function.h | 5 | ||||
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineAlways.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineCost.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 39 |
9 files changed, 36 insertions, 22 deletions
diff --git a/include/llvm/Function.h b/include/llvm/Function.h index d47746d161..3aef7c5da9 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -159,6 +159,11 @@ public: /// const FunctionNotes &getNotes() const { return Notes; } + /// hasNote - Return true if this function has given note. + bool hasNote(FunctionNotes N) const { + return (!isDeclaration() && (Notes & N)); + } + /// setNotes - Set notes for this function /// void setNotes(const FunctionNotes P) { Notes = Notes | P;} diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 678b619f7e..aae38a0423 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -160,7 +160,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) { SwitchToTextSection(SectionName.c_str()); unsigned FnAlign = OptimizeForSize ? 1 : 4; - if (FnAlign == 4 && (F->getNotes() & FN_NOTE_OptimizeForSize)) + if (F->hasNote(FN_NOTE_OptimizeForSize)) FnAlign = 1; switch (F->getLinkage()) { default: assert(0 && "Unknown linkage type!"); diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp index 25a1995ca7..12a083aa74 100644 --- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp @@ -147,7 +147,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) { SwitchToTextSection(getSectionForFunction(*F).c_str(), F); unsigned FnAlign = OptimizeForSize ? 1 : 4; - if (FnAlign == 4 && (F->getNotes() & FN_NOTE_OptimizeForSize)) + if (F->hasNote(FN_NOTE_OptimizeForSize)) FnAlign = 1; switch (F->getLinkage()) { default: assert(0 && "Unsupported linkage type!"); diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp index 5568937b02..ddcc79cf59 100644 --- a/lib/Transforms/IPO/InlineAlways.cpp +++ b/lib/Transforms/IPO/InlineAlways.cpp @@ -63,7 +63,7 @@ bool AlwaysInliner::doInitialization(CallGraph &CG) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration() && I->getNotes() != FN_NOTE_AlwaysInline) + if (!I->isDeclaration() && !I->hasNote(FN_NOTE_AlwaysInline)) NeverInline.insert(I); return false; diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 8bc256392f..6fb695dc18 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -65,7 +65,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration() && (I->getNotes() & FN_NOTE_NoInline)) + if (I->hasNote(FN_NOTE_NoInline)) NeverInline.insert(I); // Get llvm.noinline diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index d9609489a9..447bd6fb7d 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { int CurrentThreshold = InlineThreshold; Function *Fn = CS.getCaller(); - if (Fn && (Fn->getNotes() & FN_NOTE_OptimizeForSize) + if (Fn && Fn->hasNote(FN_NOTE_OptimizeForSize) && InlineThreshold != 50) { CurrentThreshold = 50; } diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 1c4bba295b..aa9158ed50 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -430,7 +430,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){ Function *F = loopHeader->getParent(); // Do not unswitch if the function is optimized for size. - if (F->getNotes() & FN_NOTE_OptimizeForSize) + if (F->hasNote(FN_NOTE_OptimizeForSize)) return false; // Check to see if it would be profitable to unswitch current loop. diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index 2eaec06b35..2a39158d24 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/lib/Transforms/Utils/InlineCost.cpp @@ -222,7 +222,7 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS, if (CalleeFI.NeverInline) return 2000000000; - if (Callee->getNotes() & FN_NOTE_AlwaysInline) + if (Callee->hasNote(FN_NOTE_AlwaysInline)) return -2000000000; // Add to the inline quality for properties that make the call valuable to diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index daf3a31a29..1088236c10 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1407,28 +1407,37 @@ void AssemblyWriter::printFunction(const Function *F) { Out << " align " << F->getAlignment(); if (F->hasGC()) Out << " gc \"" << F->getGC() << '"'; - FunctionNotes FNotes = F->getNotes(); - if (FNotes != FN_NOTE_None) { - Out << " notes("; - bool NeedComma = false; - if (FNotes & FN_NOTE_AlwaysInline) { - NeedComma = true; + if (F->isDeclaration()) { + Out << "\n"; + } else { + + bool insideNotes = false; + if (F->hasNote(FN_NOTE_AlwaysInline)) { + Out << "notes("; + insideNotes = true; Out << "inline=always"; } - else if (FNotes & FN_NOTE_NoInline) { - NeedComma = true; + if (F->hasNote(FN_NOTE_NoInline)) { + if (insideNotes) + Out << ","; + else { + Out << "notes("; + insideNotes = true; + } Out << "inline=never"; } - if (FNotes & FN_NOTE_OptimizeForSize) { - if (NeedComma) + if (F->hasNote(FN_NOTE_OptimizeForSize)) { + if (insideNotes) Out << ","; + else { + Out << "notes("; + insideNotes = true; + } Out << "opt_size"; } - Out << ")"; - } - if (F->isDeclaration()) { - Out << "\n"; - } else { + if (insideNotes) + Out << ")"; + Out << " {"; // Output all of its basic blocks... for the function |