diff --git a/opts/CMakeLists.txt b/opts/CMakeLists.txt index e017de8..c5d23a0 100644 --- a/opts/CMakeLists.txt +++ b/opts/CMakeLists.txt @@ -1,3 +1,11 @@ +find_package(LLVM) +include(AddLLVM) + +add_definitions(${LLVM_DEFINITIONS}) +include_directories(${LLVM_INCLUDE_DIRS}) +link_directories(${LLVM_LIBRARY_DIRS}) + + add_llvm_loadable_module( libGNUObjCRuntime ClassIMPCache.cpp ClassMethodInliner.cpp @@ -10,13 +18,15 @@ add_llvm_loadable_module( libGNUObjCRuntime TypeFeedback.cpp ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -DLLVM_MAJOR=3 -DLLVM_MINOR=0") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -DLLVM_MAJOR=3 -DLLVM_MINOR=2") + +set(CMAKE_CXX "clang++") + +EXEC_PROGRAM(llvm-config + ARGS --src-root + OUTPUT_VARIABLE LLVM_SRC) +EXEC_PROGRAM(llvm-config + ARGS --obj-root + OUTPUT_VARIABLE LLVM_OBJ) +include_directories( ${LLVM_INCLUDE_DIRS} "${LLVM_SRC}/include/" "${LLVM_OBJ}/include/") -add_llvm_library_dependencies( libGNUObjCRuntime - LLVMAnalysis - LLVMCore - LLVMSupport - LLVMTarget - LLVMipa - LLVMipo -) diff --git a/opts/ClassIMPCache.cpp b/opts/ClassIMPCache.cpp index e427eec..e43b97e 100644 --- a/opts/ClassIMPCache.cpp +++ b/opts/ClassIMPCache.cpp @@ -6,7 +6,6 @@ #include "llvm/Constants.h" #include "llvm/GlobalVariable.h" #include "llvm/Support/CallSite.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/DefaultPasses.h" #include "ObjectiveCOpts.h" diff --git a/opts/ClassLookupCache.cpp b/opts/ClassLookupCache.cpp index 0f74cf0..dde9ffb 100644 --- a/opts/ClassLookupCache.cpp +++ b/opts/ClassLookupCache.cpp @@ -4,7 +4,6 @@ #include "llvm/Instructions.h" #include "llvm/Constants.h" #include "llvm/GlobalVariable.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/ADT/StringMap.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" diff --git a/opts/ClassMethodInliner.cpp b/opts/ClassMethodInliner.cpp index dff8b71..5451fe0 100644 --- a/opts/ClassMethodInliner.cpp +++ b/opts/ClassMethodInliner.cpp @@ -6,7 +6,6 @@ #include "llvm/Constants.h" #include "llvm/LLVMContext.h" #include "llvm/GlobalVariable.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/InlineCost.h" #include "llvm/DefaultPasses.h" diff --git a/opts/IMPCacher.cpp b/opts/IMPCacher.cpp index b6b5f49..062dcbe 100644 --- a/opts/IMPCacher.cpp +++ b/opts/IMPCacher.cpp @@ -7,7 +7,6 @@ #include "llvm/Constants.h" #include "llvm/LLVMContext.h" #include "llvm/Metadata.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Support/CallSite.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Cloning.h" diff --git a/opts/LLVMCompat.h b/opts/LLVMCompat.h index 85f472c..df2e5fe 100644 --- a/opts/LLVMCompat.h +++ b/opts/LLVMCompat.h @@ -10,7 +10,11 @@ #include #include #include +#if LLVM_MAJOR < 3 || (LLVM_MAJOR >=3 && LLVM_MINOR < 2) #include +#else +#include +#endif // Only preserve names in a debug build. This simplifies the diff --git a/opts/LoopIMPCachePass.cpp b/opts/LoopIMPCachePass.cpp index 21fcfe1..92d7fb4 100644 --- a/opts/LoopIMPCachePass.cpp +++ b/opts/LoopIMPCachePass.cpp @@ -4,7 +4,6 @@ #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Constants.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/Verifier.h" #include "llvm/DefaultPasses.h" diff --git a/opts/Makefile b/opts/Makefile deleted file mode 100644 index aa78b06..0000000 --- a/opts/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -LEVEL = ../../../ -LIBRARYNAME = libGNUObjCRuntime -LOADABLE_MODULE = 1 -USEDLIBS = -CPPFLAGS += `llvm-config --version | sed 's/\([0-9]*\).\([0-9]*\).*/-DLLVM_MAJOR=\1 -DLLVM_MINOR=\2/'` -CPPFLAGS += -Wno-variadic-macros - -include $(LEVEL)/Makefile.common diff --git a/opts/TypeFeedback.cpp b/opts/TypeFeedback.cpp index 8c940ef..3d197c5 100644 --- a/opts/TypeFeedback.cpp +++ b/opts/TypeFeedback.cpp @@ -4,7 +4,6 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Support/CallSite.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Linker.h" #include @@ -131,7 +130,12 @@ namespace { ctors.size()), ctors)); // Create the new global and replace the old one GlobalVariable *NGV = new GlobalVariable(CA->getType(), - GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->isThreadLocal()); + GCL->isConstant(), GCL->getLinkage(), CA, "", +#if LLVM_MAJOR < 3 || (LLVM_MAJOR == 3 && LLVM_MINOR < 2) + GCL->isThreadLocal()); +#else + GCL-> getThreadLocalMode()); +#endif GCL->getParent()->getGlobalList().insert(GCL, NGV); NGV->takeName(GCL); GCL->replaceAllUsesWith(NGV); diff --git a/opts/TypeFeedbackDrivenInliner.cpp b/opts/TypeFeedbackDrivenInliner.cpp index a189f03..1047548 100644 --- a/opts/TypeFeedbackDrivenInliner.cpp +++ b/opts/TypeFeedbackDrivenInliner.cpp @@ -3,7 +3,6 @@ #include "llvm/Module.h" #include "llvm/Function.h" #include "llvm/Instructions.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Analysis/InlineCost.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Linker.h" diff --git a/opts/TypeInfoProvider.h b/opts/TypeInfoProvider.h index cd659bf..cd112d8 100644 --- a/opts/TypeInfoProvider.h +++ b/opts/TypeInfoProvider.h @@ -6,7 +6,6 @@ #include "llvm/Constants.h" #include "llvm/LLVMContext.h" #include "llvm/Metadata.h" -#include "llvm/Support/IRBuilder.h" #include "llvm/Support/CallSite.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Cloning.h"