From 81131acfbc9a4ceda0c4a1468a9fe21382597510 Mon Sep 17 00:00:00 2001 From: theraven Date: Sun, 3 Jul 2011 12:52:49 +0000 Subject: [PATCH] Fix LLVM trunk compatibility. --- opts/LLVMCompat.h | 16 ++++++++++++++++ opts/Makefile | 2 +- opts/TypeFeedback.cpp | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/opts/LLVMCompat.h b/opts/LLVMCompat.h index d7df502..c78712a 100644 --- a/opts/LLVMCompat.h +++ b/opts/LLVMCompat.h @@ -27,3 +27,19 @@ MDNode* CreateMDNode(LLVMContext &C, return MDNode::get(C, val); #endif } + +#if LLVM_MAJOR < 3 +#define GetStructType(context, ...) StructType::get(context, __VA_ARGS__) +#else +#define GetStructType(context, ...) StructType::get(__VA_ARGS__) +#endif + +__attribute((unused)) static inline +Constant* GetConstantStruct(LLVMContext &C, const std::vector + &V, bool Packed) { +#if LLVM_MAJOR < 3 + return ConstantStruct::get(C, V, Packed); +#else + return ConstantStruct::getAnon(C, V, Packed); +#endif +} diff --git a/opts/Makefile b/opts/Makefile index 46e15e0..aa78b06 100644 --- a/opts/Makefile +++ b/opts/Makefile @@ -3,6 +3,6 @@ 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 90fe6eb..25e0883 100644 --- a/opts/TypeFeedback.cpp +++ b/opts/TypeFeedback.cpp @@ -9,6 +9,7 @@ #include using namespace llvm; +#include "LLVMCompat.h" namespace { struct GNUObjCTypeFeedback : public ModulePass { @@ -113,7 +114,7 @@ namespace { std::vector CSVals; CSVals.push_back(ConstantInt::get(Type::getInt32Ty(VMContext),65535)); CSVals.push_back(init); - ctors.push_back(ConstantStruct::get(GCL->getContext(), CSVals, false)); + ctors.push_back(GetConstantStruct(GCL->getContext(), CSVals, false)); // Create the array initializer. CA = cast(ConstantArray::get(ArrayType::get(ctorTy, ctors.size()), ctors));