Merge pull request #793 from ifilippov/master

Support LLVM trunk (build and errors)
This commit is contained in:
Dmitry Babokin
2014-05-27 12:39:16 +04:00
2 changed files with 18 additions and 3 deletions

View File

@@ -69,6 +69,7 @@
#include "llvm/IR/CallSite.h" #include "llvm/IR/CallSite.h"
#include "llvm/IR/CFG.h" #include "llvm/IR/CFG.h"
#include "llvm/IR/GetElementPtrTypeIterator.h" #include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/Support/FileSystem.h"
#else #else
#include "llvm/Analysis/Verifier.h" #include "llvm/Analysis/Verifier.h"
#include <llvm/Assembly/PrintModulePass.h> #include <llvm/Assembly/PrintModulePass.h>
@@ -1770,7 +1771,7 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) {
// Resolve potential alias. // Resolve potential alias.
if (const llvm::GlobalAlias *GA = llvm::dyn_cast<llvm::GlobalAlias>(Operand)) { if (const llvm::GlobalAlias *GA = llvm::dyn_cast<llvm::GlobalAlias>(Operand)) {
#if defined(LLVM_3_5) #if defined(LLVM_3_5)
if (const llvm::Value *V = GA->getAliasedGlobal()) if (const llvm::Value *V = GA->getAliasee())
#else #else
if (const llvm::Value *V = GA->resolveAliasedGlobal(false)) if (const llvm::Value *V = GA->resolveAliasedGlobal(false))
#endif #endif

View File

@@ -1569,6 +1569,8 @@ lExtractFirstVectorElement(llvm::Value *v,
phiMap); phiMap);
llvm::Value *v1 = lExtractFirstVectorElement(bop->getOperand(1), llvm::Value *v1 = lExtractFirstVectorElement(bop->getOperand(1),
phiMap); phiMap);
Assert(v0 != NULL);
Assert(v1 != NULL);
// Note that the new binary operator is inserted immediately before // Note that the new binary operator is inserted immediately before
// the previous vector one // the previous vector one
return llvm::BinaryOperator::Create(bop->getOpcode(), v0, v1, return llvm::BinaryOperator::Create(bop->getOpcode(), v0, v1,
@@ -1615,10 +1617,22 @@ lExtractFirstVectorElement(llvm::Value *v,
return scalarPhi; return scalarPhi;
} }
// We should consider "shuffle" case and "insertElement" case separately.
// For example we can have shuffle(mul, undef, zero) but function
// "LLVMFlattenInsertChain" can handle only case shuffle(insertElement, undef, zero).
// Also if we have insertElement under shuffle we will handle it the next call of
// "lExtractFirstVectorElement" function.
if (llvm::isa<llvm::ShuffleVectorInst>(v)) {
llvm::ShuffleVectorInst *shuf = llvm::dyn_cast<llvm::ShuffleVectorInst>(v);
llvm::Value *indices = shuf->getOperand(2);
if (llvm::isa<llvm::ConstantAggregateZero>(indices)) {
return lExtractFirstVectorElement(shuf->getOperand(0), phiMap);
}
}
// If we have a chain of insertelement instructions, then we can just // If we have a chain of insertelement instructions, then we can just
// flatten them out and grab the value for the first one. // flatten them out and grab the value for the first one.
if (llvm::isa<llvm::InsertElementInst>(v) || if (llvm::isa<llvm::InsertElementInst>(v)) {
llvm::isa<llvm::ShuffleVectorInst>(v)) {
return LLVMFlattenInsertChain(v, vt->getNumElements(), false); return LLVMFlattenInsertChain(v, vt->getNumElements(), false);
} }