Index: include/llvm-c/Support.h =================================================================== --- include/llvm-c/Support.h +++ include/llvm-c/Support.h @@ -58,6 +58,24 @@ void LLVMParseCommandLineOptions(int argc, const char *const *argv, const char *Overview); +/** + * This function will search through all previously loaded dynamic + * libraries for the symbol \p symbolName. If it is found, the address of + * that symbol is returned. If not, null is returned. + * + * @see sys::DynamicLibrary::SearchForAddressOfSymbol() + */ +void *LLVMSearchForAddressOfSymbol(const char *symbolName); + +/** + * This functions permanently adds the symbol \p symbolName with the + * value \p symbolValue. These symbols are searched before any + * libraries. + * + * @see sys::DynamicLibrary::AddSymbol() + */ +void LLVMAddSymbol(const char *symbolName, void *symbolValue); + #ifdef __cplusplus } #endif Index: include/llvm-c/Transforms/PassManagerBuilder.h =================================================================== --- include/llvm-c/Transforms/PassManagerBuilder.h +++ include/llvm-c/Transforms/PassManagerBuilder.h @@ -38,21 +38,55 @@ LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, unsigned OptLevel); +/** See llvm::PassManagerBuilder::OptLevel. */ +unsigned +LLVMPassManagerBuilderGetOptLevel(LLVMPassManagerBuilderRef PMB); + /** See llvm::PassManagerBuilder::SizeLevel. */ void LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, unsigned SizeLevel); +/** See llvm::PassManagerBuilder::SizeLevel. */ +unsigned +LLVMPassManagerBuilderGetSizeLevel(LLVMPassManagerBuilderRef PMB); + /** See llvm::PassManagerBuilder::DisableUnitAtATime. */ void LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, LLVMBool Value); +/** See llvm::PassManagerBuilder::DisableUnitAtATime. */ +LLVMBool +LLVMPassManagerBuilderGetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB); + /** See llvm::PassManagerBuilder::DisableUnrollLoops. */ void LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, LLVMBool Value); +/** See llvm::PassManagerBuilder::DisableUnrollLoops. */ +LLVMBool +LLVMPassManagerBuilderGetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB); + +/** See llvm::PassManagerBuilder::LoopVectorize. */ +void +LLVMPassManagerBuilderSetLoopVectorize(LLVMPassManagerBuilderRef PMB, + LLVMBool Value); + +/** See llvm::PassManagerBuilder::LoopVectorize. */ +LLVMBool +LLVMPassManagerBuilderGetLoopVectorize(LLVMPassManagerBuilderRef PMB); + +/** See llvm::PassManagerBuilder::SLPVectorize. */ +void +LLVMPassManagerBuilderSetSLPVectorize(LLVMPassManagerBuilderRef PMB, + LLVMBool Value); + +/** See llvm::PassManagerBuilder::SLPVectorize. */ +LLVMBool +LLVMPassManagerBuilderGetSLPVectorize(LLVMPassManagerBuilderRef PMB); + /** See llvm::PassManagerBuilder::DisableSimplifyLibCalls */ void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, Index: lib/Support/DynamicLibrary.cpp =================================================================== --- lib/Support/DynamicLibrary.cpp +++ lib/Support/DynamicLibrary.cpp @@ -178,3 +178,12 @@ LLVMBool LLVMLoadLibraryPermanently(const char* Filename) { return llvm::sys::DynamicLibrary::LoadLibraryPermanently(Filename); } + +void *LLVMSearchForAddressOfSymbol(const char *symbolName) { + return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(symbolName); +} + +void LLVMAddSymbol(const char *symbolName, void *symbolValue) { + return llvm::sys::DynamicLibrary::AddSymbol(symbolName, symbolValue); +} + Index: lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- lib/Transforms/IPO/PassManagerBuilder.cpp +++ lib/Transforms/IPO/PassManagerBuilder.cpp @@ -570,6 +570,13 @@ Builder->OptLevel = OptLevel; } +unsigned +LLVMPassManagerBuilderGetOptLevel(LLVMPassManagerBuilderRef PMB) +{ + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->OptLevel; +} + void LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, unsigned SizeLevel) { @@ -577,6 +584,12 @@ Builder->SizeLevel = SizeLevel; } +unsigned +LLVMPassManagerBuilderGetSizeLevel(LLVMPassManagerBuilderRef PMB) { + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->SizeLevel; +} + void LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, LLVMBool Value) { @@ -584,6 +597,12 @@ Builder->DisableUnitAtATime = Value; } +LLVMBool +LLVMPassManagerBuilderGetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB) { + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->DisableUnitAtATime; +} + void LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, LLVMBool Value) { @@ -591,6 +610,38 @@ Builder->DisableUnrollLoops = Value; } +LLVMBool +LLVMPassManagerBuilderGetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB) { + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->DisableUnrollLoops; +} + +void +LLVMPassManagerBuilderSetLoopVectorize(LLVMPassManagerBuilderRef PMB, + LLVMBool Value) { + PassManagerBuilder *Builder = unwrap(PMB); + Builder->LoopVectorize = Value; +} + +LLVMBool +LLVMPassManagerBuilderGetLoopVectorize(LLVMPassManagerBuilderRef PMB) { + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->LoopVectorize; +} + +void +LLVMPassManagerBuilderSetSLPVectorize(LLVMPassManagerBuilderRef PMB, + LLVMBool Value) { + PassManagerBuilder *Builder = unwrap(PMB); + Builder->SLPVectorize = Value; +} + +LLVMBool +LLVMPassManagerBuilderGetSLPVectorize(LLVMPassManagerBuilderRef PMB) { + PassManagerBuilder *Builder = unwrap(PMB); + return Builder->SLPVectorize; +} + void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, LLVMBool Value) { Index: unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp =================================================================== --- unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp +++ unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp @@ -296,8 +296,16 @@ passBuilder = LLVMPassManagerBuilderCreate(); LLVMPassManagerBuilderSetOptLevel(passBuilder, 2); + ASSERT_EQ(2U, LLVMPassManagerBuilderGetOptLevel(passBuilder)); LLVMPassManagerBuilderSetSizeLevel(passBuilder, 0); - + ASSERT_EQ(0U, LLVMPassManagerBuilderGetSizeLevel(passBuilder)); + LLVMPassManagerBuilderSetDisableUnrollLoops(passBuilder, true); + ASSERT_EQ(true, LLVMPassManagerBuilderGetDisableUnrollLoops(passBuilder)); + LLVMPassManagerBuilderSetLoopVectorize(passBuilder, true); + ASSERT_EQ(true, LLVMPassManagerBuilderGetLoopVectorize(passBuilder)); + LLVMPassManagerBuilderSetSLPVectorize(passBuilder, true); + ASSERT_EQ(true, LLVMPassManagerBuilderGetSLPVectorize(passBuilder)); + LLVMPassManagerRef functionPasses = LLVMCreateFunctionPassManagerForModule(Module); LLVMPassManagerRef modulePasses = @@ -339,7 +347,8 @@ buildMCJITOptions(); buildMCJITEngine(); buildAndRunPasses(); - + buildAndRunOptPasses(); + union { void *raw; int (*usable)();