diff --git a/cbackend.cpp b/cbackend.cpp index b433240e..f5fa85c7 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -71,7 +71,11 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "llvm/Support/InstVisitor.h" +#if defined(LLVM_3_3) + #include "llvm/InstVisitor.h" +#else + #include "llvm/Support/InstVisitor.h" +#endif #include "llvm/Support/MathExtras.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/Host.h" diff --git a/ispc.cpp b/ispc.cpp index e5a287e7..af066063 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -129,9 +129,9 @@ lGetSystemISA() { static const char *supportedCPUs[] = { "atom", "penryn", "core2", "corei7", "corei7-avx" -#ifdef LLVM_3_2 +#if defined(LLVM_3_2) || defined(LLVM_3_3) , "core-avx-i", "core-avx2" -#endif // LLVM_3_2 +#endif // LLVM_3_2 or LLVM_3_3 }; diff --git a/module.cpp b/module.cpp index be6796af..b99153b7 100644 --- a/module.cpp +++ b/module.cpp @@ -1075,6 +1075,23 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } +/** Given a pointer to an element of a structure, see if it is a struct + type or an array of a struct type. If so, return a pointer to the + underlying struct type. */ +static const StructType * +lGetElementStructType(const Type *t) { + const StructType *st = CastType(t); + if (st != NULL) + return st; + + const ArrayType *at = CastType(t); + if (at != NULL) + return lGetElementStructType(at->GetElementType()); + + return NULL; +} + + /** Emits a declaration for the given struct to the given file. This function first makes sure that declarations for any structs that are (recursively) members of this struct are emitted first. @@ -1092,7 +1109,7 @@ lEmitStructDecl(const StructType *st, std::vector *emittedSt // Otherwise first make sure any contained structs have been declared. for (int i = 0; i < st->GetElementCount(); ++i) { const StructType *elementStructType = - CastType(st->GetElementType(i)); + lGetElementStructType(st->GetElementType(i)); if (elementStructType != NULL) lEmitStructDecl(elementStructType, emittedStructs, file); }