* \author Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 2
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/IR/DataLayout.h"
#endif /* LLVM_VERSION_MINOR <= 2 */
+#if LLVM_VERSION_MINOR >= 5
+#include "llvm/Linker/Linker.h"
+#else
#include "llvm/Linker.h"
+#endif
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/raw_ostream.h"
#include "ir/unit.hpp"
#include "ir/printf.hpp"
#include "llvm/llvm_to_gen.hpp"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Transforms/Utils/Cloning.h"
*
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MINOR <= 2
#include "llvm/Function.h"
#include "llvm/InstrTypes.h"
#else
#include "llvm/IR/IRBuilder.h"
#endif /* LLVM_VERSION_MINOR <= 1 */
-#include "llvm/Support/CallSite.h"
-#include "llvm/Support/CFG.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Attributes.h"
* is intercepted, we just abort
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MINOR <= 2
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#else
#include "llvm/IR/DataLayout.h"
#endif
+
+#if LLVM_VERSION_MINOR >= 5
+#include "llvm/IR/CallSite.h"
+#include "llvm/IR/CFG.h"
+#else
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h"
+#endif
+
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR <= 2)
#include "llvm/Support/InstVisitor.h"
+#elif LLVM_VERSION_MINOR >= 5
+#include "llvm/IR/InstVisitor.h"
#else
#include "llvm/InstVisitor.h"
#endif
#include "llvm/Support/Host.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/SourceMgr.h"
-#include "llvm/Config/config.h"
#include "llvm/llvm_gen_backend.hpp"
#include "ir/context.hpp"
// If the "taken" successor is the next block, we try to invert the
// branch.
BasicBlock *succ = I->getSuccessor(0);
- if (llvm::next(Function::iterator(bb)) != Function::iterator(succ))
+ if (std::next(Function::iterator(bb)) != Function::iterator(succ))
return;
// More than one use is too complicated: we skip it
// one instruction that use the local variable, simply return.
const Instruction *insn = NULL;
for(Value::const_use_iterator iter = v->use_begin(); iter != v->use_end(); ++iter) {
- if(isa<Instruction>(*iter)) return cast<const Instruction>(*iter);
- insn = getInstructionUseLocal(*iter);
+ // After LLVM 3.5, use_iterator points to 'Use' instead of 'User', which is more straightforward.
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
+ const User *theUser = *iter;
+#else
+ const User *theUser = iter->getUser();
+#endif
+ if(isa<Instruction>(theUser)) return cast<const Instruction>(theUser);
+ insn = getInstructionUseLocal(theUser);
if(insn != NULL) break;
}
return insn;
// successor
if (I.isConditional() == false) {
BasicBlock *target = I.getSuccessor(0);
- if (llvm::next(Function::iterator(bb)) != Function::iterator(target)) {
+ if (std::next(Function::iterator(bb)) != Function::iterator(target)) {
GBE_ASSERT(labelMap.find(target) != labelMap.end());
const ir::LabelIndex labelIndex = labelMap[target];
ctx.BRA(labelIndex);
// If non-taken target is the next block, there is nothing to do
BasicBlock *bb = I.getParent();
- if (llvm::next(Function::iterator(bb)) == Function::iterator(nonTaken))
+ if (std::next(Function::iterator(bb)) == Function::iterator(nonTaken))
return;
// This is slightly more complicated here. We need to issue one more
* \author Yang Rong <rong.r.yang@intel.com>
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MINOR <= 2
#include "llvm/Function.h"
#include "llvm/InstrTypes.h"
#else
#include "llvm/IR/IRBuilder.h"
#endif /* LLVM_VERSION_MINOR <= 1 */
-#include "llvm/Support/CallSite.h"
-#include "llvm/Support/CFG.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/llvm_gen_backend.hpp"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PostOrderIterator.h"
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 2
#else
#include "llvm/IR/IRBuilder.h"
#endif /* LLVM_VERSION_MINOR <= 1 */
-#include "llvm/Support/CallSite.h"
-#include "llvm/Support/CFG.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
public:
static char ID;
ScalarEvolution *SE;
- DataLayout *TD;
+ const DataLayout *TD;
GenLoadStoreOptimization() : BasicBlockPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const {
virtual bool runOnBasicBlock(BasicBlock &BB) {
SE = &getAnalysis<ScalarEvolution>();
- TD = getAnalysisIfAvailable<DataLayout>();
+ #if LLVM_VERSION_MINOR >= 5
+ DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
+ TD = DLP ? &DLP->getDataLayout() : nullptr;
+ #else
+ TD = getAnalysisIfAvailable<DataLayout>();
+ #endif
return optimizeLoadStore(BB);
}
Type *getValueType(Value *insn);
* Segovia) the right to use another license for it (MIT here)
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MINOR <= 2
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#else
#include "llvm/IR/DataLayout.h"
#endif
-#include "llvm/Support/CallSite.h"
-#include "llvm/Support/CFG.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR <= 2)
#include "llvm/Support/InstVisitor.h"
+#elif LLVM_VERSION_MINOR >= 5
+#include "llvm/IR/InstVisitor.h"
#else
#include "llvm/InstVisitor.h"
#endif
#include "llvm/Support/Host.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/SourceMgr.h"
-#include "llvm/Config/config.h"
#include "llvm/llvm_gen_backend.hpp"
#include "ir/unit.hpp"
#include <stdio.h>
#include <stdlib.h>
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MINOR <= 2
#include "llvm/Function.h"
#include "llvm/InstrTypes.h"
#else
#include "llvm/IR/IRBuilder.h"
#endif /* LLVM_VERSION_MINOR <= 1 */
+
+#if LLVM_VERSION_MINOR >= 5
+#include "llvm/IR/CallSite.h"
+#include "llvm/IR/CFG.h"
+#else
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h"
+#endif
+
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Attributes.h"
//
//===----------------------------------------------------------------------===//
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PostOrderIterator.h"
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 2
#else
#include "llvm/IR/IRBuilder.h"
#endif /* LLVM_VERSION_MINOR <= 1 */
+
+#if LLVM_VERSION_MINOR >= 5
+#include "llvm/IR/CallSite.h"
+#include "llvm/IR/CFG.h"
+#else
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h"
+#endif
#include "llvm/Support/raw_ostream.h"
#include "llvm/llvm_gen_backend.hpp"
* \author Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 2
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
void runFuntionPass(Module &mod, TargetLibraryInfo *libraryInfo)
{
FunctionPassManager FPM(&mod);
+
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+ FPM.add(new DataLayoutPass(&mod));
+#else
FPM.add(new DataLayout(&mod));
+#endif
+
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=5
FPM.add(createVerifierPass(true));
#else
{
llvm::PassManager MPM;
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+ MPM.add(new DataLayoutPass(&mod));
+#else
MPM.add(new DataLayout(&mod));
+#endif
MPM.add(new TargetLibraryInfo(*libraryInfo));
MPM.add(createTypeBasedAliasAnalysisPass());
MPM.add(createBasicAliasAnalysisPass());
runModulePass(mod, libraryInfo, optLevel);
llvm::PassManager passes;
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
+ passes.add(new DataLayoutPass(&mod));
+#else
passes.add(new DataLayout(&mod));
+#endif
// Print the code before further optimizations
if (OCL_OUTPUT_LLVM_BEFORE_EXTRA_PASS)
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
#undef INLINE
/* The printf function. */
+/* From LLVM 3.5, c string are all in constant address space */
+#if 100*__clang_major__ + __clang_minor__ < 305
int __gen_ocl_printf_stub(const char * format, ...);
+#else
+int __gen_ocl_printf_stub(constant char * format, ...);
+#endif
#define printf __gen_ocl_printf_stub
#endif /* __GEN_OCL_STDLIB_H__ */