@@ -399,6 +399,7 @@ bool Program::build(BuildType buildType, const char* options,
399399 // Pre-compiled header
400400 char * pchdir = NULL ;
401401 char * pch = NULL ;
402+ #if LLVM_VERSION < 210 || LLVM_VERSION >= 230
402403 if (!checkEnv (" OCLGRIND_DISABLE_PCH" ) &&
403404 (!strcmp (clstd, " -cl-std=CL1.2" ) || !strcmp (clstd, " -cl-std=CL2.0" )))
404405 {
@@ -466,6 +467,7 @@ bool Program::build(BuildType buildType, const char* options,
466467 buildLog << " WARNING: Unable to determine precompiled header path\n " ;
467468 }
468469 }
470+ #endif
469471
470472 if (pch)
471473 {
@@ -490,6 +492,20 @@ bool Program::build(BuildType buildType, const char* options,
490492 clang::DiagnosticOptions* diagOpts = new clang::DiagnosticOptions ();
491493 llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagID (
492494 new clang::DiagnosticIDs ());
495+
496+ #if LLVM_VERSION >= 210
497+ clang::TextDiagnosticPrinter* diagConsumer =
498+ new clang::TextDiagnosticPrinter (buildLog, *diagOpts, false );
499+ clang::DiagnosticsEngine diags (diagID, *diagOpts, diagConsumer);
500+
501+ // Create compiler invocation and instance.
502+ std::shared_ptr<clang::CompilerInvocation> invocation (
503+ new clang::CompilerInvocation);
504+ clang::CompilerInvocation::CreateFromArgs (*invocation, args, diags);
505+ clang::CompilerInstance compiler (invocation);
506+ compiler.createDiagnostics (*llvm::vfs::getRealFileSystem (), diagConsumer,
507+ false );
508+ #else
493509 clang::TextDiagnosticPrinter* diagConsumer =
494510 new clang::TextDiagnosticPrinter (buildLog, diagOpts);
495511 clang::DiagnosticsEngine diags (diagID, diagOpts, diagConsumer);
@@ -509,6 +525,7 @@ bool Program::build(BuildType buildType, const char* options,
509525 clang::CompilerInvocation::CreateFromArgs (*invocation, args,
510526 compiler.getDiagnostics ());
511527 compiler.setInvocation (invocation);
528+ #endif
512529
513530 // Remap include files
514531 std::unique_ptr<llvm::MemoryBuffer> buffer;
@@ -961,8 +978,10 @@ llvm::GetElementPtrInst* createScalarGEP(llvm::Value* ptr, llvm::Value* index,
961978 auto byteOffset =
962979 getTypeSize (store->getValueOperand ()->getType ()->getScalarType ());
963980 auto * mul = llvm::BinaryOperator::CreateMul (
964- index, llvm::Constant::getIntegerValue (index->getType (),
965- llvm::APInt (32 , byteOffset)));
981+ index,
982+ llvm::Constant::getIntegerValue (
983+ index->getType (),
984+ llvm::APInt (index->getType ()->getIntegerBitWidth (), byteOffset)));
966985 mul->insertBefore (store);
967986 indices.push_back (mul);
968987 }
0 commit comments