[llvm-commits] [llvm-gcc-4.2] r58101 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
Daniel Dunbar
daniel at zuster.org
Fri Oct 24 11:17:56 PDT 2008
Author: ddunbar
Date: Fri Oct 24 13:17:55 2008
New Revision: 58101
URL: http://llvm.org/viewvc/llvm-project?rev=58101&view=rev
Log:
Revert r58018, bug fixes were causing unintended regressions in gcc
test suite. Will investigate further.
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=58101&r1=58100&r2=58101&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri Oct 24 13:17:55 2008
@@ -379,8 +379,19 @@
// FIXME: AT -O0/O1, we should stream out functions at a time.
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->hasFnAttr(Attribute::AlwaysInline)) {
+ NeedAlwaysInliner = true;
+ break;
+ }
if (optimize > 0 && !DisableLLVMOptimizations) {
+ HasPerModulePasses = true;
PassManager *PM = PerModulePasses;
if (flag_unit_at_a_time)
PM->add(createRaiseAllocationsPass()); // call %malloc -> malloc inst
@@ -401,7 +412,7 @@
}
if (flag_inline_trees > 1) // respect -fno-inline-functions
PM->add(createFunctionInliningPass()); // Inline small functions
- else
+ else if (NeedAlwaysInliner)
PM->add(createAlwaysInlinerPass()); // Inline always_inline functions
if (optimize > 2)
PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args
@@ -445,18 +456,21 @@
if (optimize > 1 && flag_unit_at_a_time)
PM->add(createConstantMergePass()); // Merge dup global constants
- } else {
- PerModulePasses->add(createAlwaysInlinerPass());
}
+ 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.
PerModulePasses->add(CreateBitcodeWriterPass(*AsmOutStream));
+ HasPerModulePasses = true;
} else if (emit_llvm) {
// Emit an LLVM .ll file to the output. This is used when passed
// -emit-llvm -S to the GCC driver.
PerModulePasses->add(createPrintModulePass(AsmOutRawStream));
+ HasPerModulePasses = true;
} else {
FunctionPassManager *PM;
@@ -464,7 +478,7 @@
// as a separate "pass" after that happens.
// FIXME: This is disabled right now until bugs can be worked out. Reenable
// this for fast -O0 compiles!
- if (1) {
+ if (HasPerModulePasses || 1) {
CodeGenPasses = PM =
new FunctionPassManager(new ExistingModuleProvider(TheModule));
PM->add(new TargetData(*TheTarget->getTargetData()));
@@ -500,6 +514,10 @@
delete PerFunctionPasses;
PerFunctionPasses = 0;
}
+ if (!HasPerModulePasses) {
+ delete PerModulePasses;
+ PerModulePasses = 0;
+ }
}
More information about the llvm-commits
mailing list