[llvm-commits] [llvm] r56477 - in /llvm/trunk: include/llvm/Function.h lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp lib/Transforms/IPO/InlineAlways.cpp lib/Transforms/IPO/InlineSimple.cpp lib/Transforms/IPO/Inliner.cpp lib/Transforms/Scalar/LoopUnswitch.cpp lib/Transforms/Utils/InlineCost.cpp lib/VMCore/AsmWriter.cpp
Devang Patel
dpatel at apple.com
Mon Sep 22 15:32:29 PDT 2008
Author: dpatel
Date: Mon Sep 22 17:32:29 2008
New Revision: 56477
URL: http://llvm.org/viewvc/llvm-project?rev=56477&view=rev
Log:
Add hasNote() to check note associated with a function.
Modified:
llvm/trunk/include/llvm/Function.h
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
llvm/trunk/lib/VMCore/AsmWriter.cpp
Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Mon Sep 22 17:32:29 2008
@@ -159,6 +159,11 @@
///
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;}
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Sep 22 17:32:29 2008
@@ -160,7 +160,7 @@
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!");
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Mon Sep 22 17:32:29 2008
@@ -147,7 +147,7 @@
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!");
Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Mon Sep 22 17:32:29 2008
@@ -63,7 +63,7 @@
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;
Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Mon Sep 22 17:32:29 2008
@@ -65,7 +65,7 @@
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
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon Sep 22 17:32:29 2008
@@ -141,7 +141,7 @@
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;
}
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Sep 22 17:32:29 2008
@@ -430,7 +430,7 @@
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.
Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Mon Sep 22 17:32:29 2008
@@ -222,7 +222,7 @@
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
Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=56477&r1=56476&r2=56477&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Sep 22 17:32:29 2008
@@ -1407,28 +1407,37 @@
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
More information about the llvm-commits
mailing list