[opengtl-commits] [319] * optimize by default at level 2 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 319
Author: cyrille
Date: 2008-08-19 12:07:57 +0200 (Tue, 19 Aug 2008)
Log Message:
-----------
* optimize by default at level 2
* better testing of default value function (to test some extreme case of optimization)
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt
trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
trunk/OpenGTL/OpenCTL/tests/statements/defaultparameter.ctl
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt 2008-08-19 10:06:01 UTC (rev 318)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt 2008-08-19 10:07:57 UTC (rev 319)
@@ -21,7 +21,7 @@
# __STDC_LIMIT_MACROS is needed by LLVM's DataTypes.h
add_definitions( "-D__STDC_LIMIT_MACROS" )
-add_definitions( -DCOUMPONENT_NAME=\"\\\"OpenCTL\\\"\" )
+add_definitions( -DCOUMPONENT_NAME="OpenCTL" )
add_definitions( -D_OPENCTL_CTL_STD_LIB_SRC_DIR_="${CMAKE_CURRENT_SOURCE_DIR}")
add_definitions( -D_OPENCTL_CTL_SHARE_DIR_="${SHARE_INSTALL_DIR}/ctl" )
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp 2008-08-19 10:06:01 UTC (rev 318)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp 2008-08-19 10:07:57 UTC (rev 319)
@@ -187,7 +187,8 @@
// Success
GTLCore::Optimiser::instance()->d->passManager()->run( *d->module );
-
+ OCTL_DEBUG( "After optimization");
+ OCTL_DEBUG( *d->module );
} else {
// Failure
OCTL_DEBUG("failure " << (*errorMessages().begin()).line() << ": " << (*errorMessages().begin()).errorMessage());
@@ -219,6 +220,8 @@
return mod;
}
+#include <llvm/ValueSymbolTable.h>
+
bool Compiler::importModule(const GTLCore::String& name)
{
Module* m = ModulesManager::instance()->loadModule( name );
@@ -238,22 +241,35 @@
// Link a copy of the module
llvm::Module* clone = llvm::CloneModule( m->data()->llvmModule() );
llvm::Linker linker("", d->module);
- linker.LinkInModule( clone );
+ GTLCore::String errorMessage;
+ linker.LinkInModule( clone, &errorMessage );
+ OCTL_DEBUG("Linking error: " << errorMessage );
linker.releaseModule();
+ for (llvm::ValueSymbolTable::const_iterator I = clone->getValueSymbolTable().begin(), E = clone->getValueSymbolTable().end(); I != E; ++I) {
+ OCTL_DEBUG( I->getKeyData() );
+ }
+ for (llvm::ValueSymbolTable::const_iterator I = d->module->getValueSymbolTable().begin(), E = d->module->getValueSymbolTable().end(); I != E; ++I) {
+ OCTL_DEBUG( I->getKeyData() );
+ }
delete clone;
+// OCTL_DEBUG( *d->module );
// Append the function coming from the imported module
std::list<GTLCore::Function*> functions = m->functions();
OCTL_DEBUG(functions.size());
for(std::list<GTLCore::Function*>::iterator it = functions.begin();
it != functions.end(); ++it)
{
+ OCTL_DEBUG("Importing " << (*it)->name() );
int min = (*it)->d->data->minimumParameters();
int max = (*it)->d->data->maximumParameters();
std::vector<llvm::Function*> functions(max + 1);
+ OCTL_DEBUG( "min = " << min << " max = " << max );
for(int i = min; i <= max; ++i)
{
GTLCore::String name = GTLCore::Function::Data::symbolName( (*it)->name(), (*it)->parameters() );
- functions[i] = d->module->getFunction(name);
+ OCTL_DEBUG("Looking for " << name );
+ OCTL_ASSERT( d->module->getFunction(name) );
+ functions[i] = d->module->getFunction(name); //llvm::GlobalValue::ExternalLinkage
}
GTLCore::Function::Data* data = new GTLCore::Function::Data( (*it)->parameters(), min );
data->setFunctions( functions );
Modified: trunk/OpenGTL/OpenCTL/tests/statements/defaultparameter.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/statements/defaultparameter.ctl 2008-08-19 10:06:01 UTC (rev 318)
+++ trunk/OpenGTL/OpenCTL/tests/statements/defaultparameter.ctl 2008-08-19 10:07:57 UTC (rev 319)
@@ -28,9 +28,16 @@
return 0;
}
+int func2(int r, int b = 12)
+{
+ assert( r == b);
+}
+
int main()
{
func(10);
+ func2(12);
+ func2(5,5);
testFunction1();
testFunction2();
return 0;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-19 10:06:01 UTC (rev 318)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-19 10:07:57 UTC (rev 319)
@@ -299,7 +299,7 @@
llvm::Function* CodeGenerator::createFunction( llvm::FunctionType* type, const GTLCore::String& name)
{
- return llvm::Function::Create( type, llvm::GlobalValue::InternalLinkage,
+ return llvm::Function::Create( type, llvm::GlobalValue::LinkOnceLinkage,
name, d->module->llvmModule() );
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp 2008-08-19 10:06:01 UTC (rev 318)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp 2008-08-19 10:07:57 UTC (rev 319)
@@ -75,7 +75,7 @@
Optimiser::Private::Private() : m_passManager(0)
{
- setLevel( 1 );
+ setLevel( 2 );
}
Optimiser::Private::~Private()