Merge pull request #409 from mmp/master

Bugfix for issue #408.
This commit is contained in:
Jean-Luc Duprat
2012-12-06 09:46:34 -08:00
3 changed files with 25 additions and 4 deletions

View File

@@ -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"

View File

@@ -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
};

View File

@@ -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<StructType>(t);
if (st != NULL)
return st;
const ArrayType *at = CastType<ArrayType>(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<const StructType *> *emittedSt
// Otherwise first make sure any contained structs have been declared.
for (int i = 0; i < st->GetElementCount(); ++i) {
const StructType *elementStructType =
CastType<StructType>(st->GetElementType(i));
lGetElementStructType(st->GetElementType(i));
if (elementStructType != NULL)
lEmitStructDecl(elementStructType, emittedStructs, file);
}