[llvm-commits] [llvm-gcc-4.2] r55741 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
Devang Patel
dpatel at apple.com
Wed Sep 3 15:46:17 PDT 2008
Author: dpatel
Date: Wed Sep 3 17:46:16 2008
New Revision: 55741
URL: http://llvm.org/viewvc/llvm-project?rev=55741&view=rev
Log:
Add AlwaysInliner to handle always_inline functions, even if the optimizer is disabled.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=55741&r1=55740&r2=55741&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Sep 3 17:46:16 2008
@@ -368,6 +368,15 @@
PerModulePasses = new PassManager();
PerModulePasses->add(new TargetData(*TheTarget->getTargetData()));
bool HasPerModulePasses = false;
+ bool NeedAlwaysInliner = false;
+ // Check if AlwaysInliner is needed to handle functions that are
+ // marked as always_inline.
+ for (Module::iterator I = TheModule->begin(), E = TheModule->end();
+ I != E; ++I)
+ if (!I->isDeclaration() && I->getNotes() == FN_NOTE_AlwaysInline) {
+ NeedAlwaysInliner = true;
+ break;
+ }
if (optimize > 0 && !DisableLLVMOptimizations) {
HasPerModulePasses = true;
@@ -386,21 +395,10 @@
PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
if (flag_unit_at_a_time && flag_exceptions)
PM->add(createPruneEHPass()); // Remove dead EH info
- if (flag_inline_trees > 1) // respect -fno-inline-functions
- PM->add(createFunctionInliningPass()); // Inline small functions
- else {
- // The inliner pass won't be inserted based on command line options.
- // Use AlwaysInliner to handle functions that are marked as always_inline.
- bool NeedAlwaysInliner = false;
- for (Module::iterator I = TheModule->begin(), E = TheModule->end();
- I != E; ++I)
- if (!I->isDeclaration() && I->getNotes() == FN_NOTE_AlwaysInline) {
- NeedAlwaysInliner = true;
- break;
- }
- if (NeedAlwaysInliner)
- PM->add(createAlwaysInlinerPass());
- }
+ if (flag_inline_trees > 1) // respect -fno-inline-functions
+ PM->add(createFunctionInliningPass()); // Inline small functions
+ else if (NeedAlwaysInliner)
+ PM->add(createAlwaysInlinerPass()); // Inline always_inline functions
if (optimize > 2)
PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args
if (!flag_no_simplify_libcalls)
@@ -445,6 +443,9 @@
PM->add(createConstantMergePass()); // Merge dup global constants
}
+ if (!HasPerModulePasses && NeedAlwaysInliner)
+ PerModulePasses->add(createAlwaysInlinerPass());
+
if (emit_llvm_bc) {
// Emit an LLVM .bc file to the output. This is used when passed
// -emit-llvm -c to the GCC driver.
More information about the llvm-commits
mailing list