Commit b9d9c185 authored by Lukasz Wesierski's avatar Lukasz Wesierski

Preparing for LLVM 8

Change-Id: Ie9b7fe677c30dad8be1debb7c41e6d7a85f5fffe
parent 7133b32f
......@@ -597,7 +597,7 @@ public:
// DISubprogram::getRawTemplateParams()
#if LLVM_VERSION_MAJOR == 4
const unsigned TemplateParamsIndex = 8;
#elif LLVM_VERSION_MAJOR == 7
#elif LLVM_VERSION_MAJOR >= 7
const unsigned TemplateParamsIndex = 9;
#endif
target->replaceOperandWith(TemplateParamsIndex, TParams.get());
......@@ -1740,7 +1740,7 @@ SPIRVToLLVM::transLifetimeInst(SPIRVInstTemplateBase* BI, BasicBlock* BB, Functi
auto ID = (BI->getOpCode() == OpLifetimeStart) ?
Intrinsic::lifetime_start :
Intrinsic::lifetime_end;
#if LLVM_VERSION_MAJOR == 7
#if LLVM_VERSION_MAJOR >= 7
auto *pFunc = Intrinsic::getDeclaration(M, ID, llvm::ArrayRef<llvm::Type*>(PointerType::getInt8PtrTy(*Context)));
#else
auto *pFunc = Intrinsic::getDeclaration(M, ID);
......
......@@ -113,7 +113,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "Compiler/MetaDataApi/SpirMetaDataApi.h"
#include "Compiler/Optimizer/FixFastMathFlags.hpp"
#include "MoveStaticAllocas.h"
#include "Compiler/Optimizer/IGCInstCombiner/4.0/IGCInstructionCombining.hpp"
#include "Compiler/Optimizer/IGCInstCombiner/IGCInstructionCombining.hpp"
#include "common/debug/Debug.hpp"
#include "common/igc_regkeys.hpp"
......
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
#if LLVM_VERSION_MAJOR == 4
#include "llvm4/Upgrader.h"
#elif LLVM_VERSION_MAJOR == 7
#include "llvm7/Upgrader.h"
#elif LLVM_VERSION_MAJOR == 8
#include "llvm8/Upgrader.h"
#endif
\ No newline at end of file
This diff is collapsed.
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
//===- llvm/Bitcode/BitcodeReader.h - Bitcode reader ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This header defines interfaces to read LLVM bitcode files/streams.
//
//===----------------------------------------------------------------------===//
#ifndef __DRIVERINTERFACE_UPGRADER_BITCODE_READER_H__
#define __DRIVERINTERFACE_UPGRADER_BITCODE_READER_H__
#include "common/LLVMWarningsPush.hpp"
#include <llvm/ADT/DenseMap.h>
#include <llvm/Bitcode/BitstreamReader.h>
#include <llvm/Bitcode/LLVMBitCodes.h>
#include "llvm/Bitcode/BitcodeReader.h"
#include <llvm/IR/Attributes.h>
#include <llvm/IR/Comdat.h>
#include <llvm/IR/DiagnosticInfo.h>
#include <llvm/IR/GVMaterializer.h>
#include <llvm/IR/Metadata.h>
#include <llvm/IR/OperandTraits.h>
#include <llvm/IR/TrackingMDRef.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/ValueHandle.h>
#include <llvm/Support/MemoryBuffer.h>
#include <deque>
#include <system_error>
#include <vector>
#include "common/LLVMWarningsPop.hpp"
namespace upgrader {
using namespace llvm;
struct BitcodeFileContents;
/// Basic information extracted from a bitcode module to be used for LTO.
struct BitcodeLTOInfo {
bool IsThinLTO;
bool HasSummary;
bool EnableSplitLTOUnit;
};
/// Represents a module in a bitcode file.
class BitcodeModule {
// This covers the identification (if present) and module blocks.
ArrayRef<uint8_t> Buffer;
StringRef ModuleIdentifier;
// The string table used to interpret this module.
StringRef Strtab;
// The bitstream location of the IDENTIFICATION_BLOCK.
uint64_t IdentificationBit;
// The bitstream location of this module's MODULE_BLOCK.
uint64_t ModuleBit;
BitcodeModule(ArrayRef<uint8_t> Buffer, StringRef ModuleIdentifier,
uint64_t IdentificationBit, uint64_t ModuleBit)
: Buffer(Buffer), ModuleIdentifier(ModuleIdentifier),
IdentificationBit(IdentificationBit), ModuleBit(ModuleBit) {}
// Calls the ctor.
friend Expected<BitcodeFileContents>
getBitcodeFileContents(MemoryBufferRef Buffer);
Expected<std::unique_ptr<Module>> getModuleImpl(LLVMContext &Context,
bool MaterializeAll,
bool ShouldLazyLoadMetadata,
bool IsImporting);
public:
StringRef getBuffer() const {
return StringRef((const char *)Buffer.begin(), Buffer.size());
}
StringRef getStrtab() const { return Strtab; }
StringRef getModuleIdentifier() const { return ModuleIdentifier; }
/// Read the bitcode module and prepare for lazy deserialization of function
/// bodies. If ShouldLazyLoadMetadata is true, lazily load metadata as well.
/// If IsImporting is true, this module is being parsed for ThinLTO
/// importing into another module.
Expected<std::unique_ptr<Module>> getLazyModule(LLVMContext &Context,
bool ShouldLazyLoadMetadata,
bool IsImporting);
/// Read the entire bitcode module and return it.
Expected<std::unique_ptr<Module>> parseModule(LLVMContext &Context);
/// Returns information about the module to be used for LTO: whether to
/// compile with ThinLTO, and whether it has a summary.
Expected<BitcodeLTOInfo> getLTOInfo();
/// Parse the specified bitcode buffer, returning the module summary index.
Expected<std::unique_ptr<ModuleSummaryIndex>> getSummary();
/// Parse the specified bitcode buffer and merge its module summary index
/// into CombinedIndex.
Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath,
uint64_t ModuleId);
};
struct BitcodeFileContents {
std::vector<BitcodeModule> Mods;
StringRef Symtab, StrtabForSymtab;
};
/// Returns the contents of a bitcode file. This includes the raw contents of
/// the symbol table embedded in the bitcode file. Clients which require a
/// symbol table should prefer to use irsymtab::read instead of this function
/// because it creates a reader for the irsymtab and handles upgrading bitcode
/// files without a symbol table or with an old symbol table.
Expected<BitcodeFileContents> getBitcodeFileContents(MemoryBufferRef Buffer);
/// Returns a list of modules in the specified bitcode buffer.
Expected<std::vector<BitcodeModule>>
getBitcodeModuleList(MemoryBufferRef Buffer);
/// Read the header of the specified bitcode buffer and prepare for lazy
/// deserialization of function bodies. If ShouldLazyLoadMetadata is true,
/// lazily load metadata as well. If IsImporting is true, this module is
/// being parsed for ThinLTO importing into another module.
Expected<std::unique_ptr<Module>>
getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context,
bool ShouldLazyLoadMetadata = false,
bool IsImporting = false);
/// Read the specified bitcode file, returning the module.
Expected<std::unique_ptr<Module>> parseBitcodeFile(MemoryBufferRef Buffer,
LLVMContext &Context);
/// Returns LTO information for the specified bitcode file.
Expected<BitcodeLTOInfo> getBitcodeLTOInfo(MemoryBufferRef Buffer);
/// Parse the specified bitcode buffer, returning the module summary index.
Expected<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndex(MemoryBufferRef Buffer);
/// Parse the specified bitcode buffer and merge the index into CombinedIndex.
Error readModuleSummaryIndex(MemoryBufferRef Buffer,
ModuleSummaryIndex &CombinedIndex,
uint64_t ModuleId);
/// Parse the module summary index out of an IR file and return the module
/// summary index object if found, or an empty summary if not. If Path refers
/// to an empty file and IgnoreEmptyThinLTOIndexFile is true, then
/// this function will return nullptr.
Expected<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndexForFile(StringRef Path,
bool IgnoreEmptyThinLTOIndexFile = false);
} // end namespace llvm
#endif
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
//===-- Bitcode/Reader/MetadataLoader.h - Load Metadatas -------*- C++ -*-====//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class handles loading Metadatas.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_BITCODE_READER_METADATALOADER_H
#define LLVM_LIB_BITCODE_READER_METADATALOADER_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Error.h"
#include <functional>
#include <memory>
namespace llvm {
class BitcodeReaderValueList;
class BitstreamCursor;
class DISubprogram;
class Error;
class Function;
class Instruction;
class Metadata;
class MDNode;
class Module;
class Type;
/// Helper class that handles loading Metadatas and keeping them available.
class MetadataLoader {
class MetadataLoaderImpl;
std::unique_ptr<MetadataLoaderImpl> Pimpl;
Error parseMetadata(bool ModuleLevel);
public:
~MetadataLoader();
MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
BitcodeReaderValueList &ValueList, bool IsImporting,
std::function<Type *(unsigned)> getTypeByID);
MetadataLoader &operator=(MetadataLoader &&);
MetadataLoader(MetadataLoader &&);
// Parse a module metadata block
Error parseModuleMetadata() { return parseMetadata(true); }
// Parse a function metadata block
Error parseFunctionMetadata() { return parseMetadata(false); }
/// Set the mode to strip TBAA metadata on load.
void setStripTBAA(bool StripTBAA = true);
/// Return true if the Loader is stripping TBAA metadata.
bool isStrippingTBAA();
// Return true there are remaining unresolved forward references.
bool hasFwdRefs() const;
/// Return the given metadata, creating a replaceable forward reference if
/// necessary.
Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
/// Return the DISubprogram metadata for a Function if any, null otherwise.
DISubprogram *lookupSubprogramForFunction(Function *F);
/// Parse a `METADATA_ATTACHMENT` block for a function.
Error parseMetadataAttachment(
Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
/// Parse a `METADATA_KIND` block for the current module.
Error parseMetadataKinds();
unsigned size() const;
void shrinkTo(unsigned N);
/// Perform bitcode upgrades on llvm.dbg.* calls.
void upgradeDebugIntrinsics(Function &F);
};
}
#endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
// vim:ts=2:sw=2:et:
#pragma warning(disable:4141)
#pragma warning(disable:4146)
#pragma warning(disable:4244)
#pragma warning(disable:4624)
#pragma warning(disable:4800)
#include "Upgrader.h"
#include "common/LLVMWarningsPush.hpp"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/raw_ostream.h>
#include "common/LLVMWarningsPop.hpp"
using namespace llvm;
std::unique_ptr<MemoryBuffer>
upgrader::upgradeBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context) {
auto ErrM = upgrader::parseBitcodeFile(Buffer, Context);
Module *M = ErrM.get().get();
if (!M)
return nullptr;
SmallVector<char, 0> Buf;
Buf.reserve(1024*1024);
raw_svector_ostream OS(Buf);
WriteBitcodeToFile(*M, OS);
return MemoryBuffer::getMemBufferCopy(OS.str());
}
Expected<std::unique_ptr<Module>>
upgrader::upgradeAndParseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context) {
return upgrader::parseBitcodeFile(Buffer, Context);
}
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
// vim:ts=2:sw=2:et:
#ifndef __DRIVERINTERFACE_UPGRADER_H__
#define __DRIVERINTERFACE_UPGRADER_H__
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/LLVMContext.h>
#include <llvm/Support/ErrorOr.h>
#include <llvm/Support/Error.h>
#include <llvm/Support/MemoryBuffer.h>
#include "common/LLVMWarningsPop.hpp"
namespace upgrader {
llvm::Expected<std::unique_ptr<llvm::Module>> parseBitcodeFile(llvm::MemoryBufferRef Buffer, llvm::LLVMContext &Context);
std::unique_ptr<llvm::MemoryBuffer> upgradeBitcodeFile(llvm::MemoryBufferRef, llvm::LLVMContext &);
llvm::Expected<std::unique_ptr<llvm::Module>> upgradeAndParseBitcodeFile(llvm::MemoryBufferRef, llvm::LLVMContext &);
} // End upgrader namespace
#endif // __DRIVERINTERFACE_UPGRADER_H__
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
//===-- Bitcode/Reader/ValueList.h - Number values --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class gives values and types Unique ID's.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_BITCODE_READER_VALUELIST_H
#define LLVM_LIB_BITCODE_READER_VALUELIST_H
#include "llvm/IR/ValueHandle.h"
#include <cassert>
#include <utility>
#include <vector>
namespace llvm {
class Constant;
class LLVMContext;
class Type;
class Value;
class BitcodeReaderValueList {
std::vector<WeakTrackingVH> ValuePtrs;
/// As we resolve forward-referenced constants, we add information about them
/// to this vector. This allows us to resolve them in bulk instead of
/// resolving each reference at a time. See the code in
/// ResolveConstantForwardRefs for more information about this.
///
/// The key of this vector is the placeholder constant, the value is the slot
/// number that holds the resolved value.
using ResolveConstantsTy = std::vector<std::pair<Constant *, unsigned>>;
ResolveConstantsTy ResolveConstants;
LLVMContext &Context;
public:
BitcodeReaderValueList(LLVMContext &C) : Context(C) {}
~BitcodeReaderValueList() {
assert(ResolveConstants.empty() && "Constants not resolved?");
}
// vector compatibility methods
unsigned size() const { return ValuePtrs.size(); }
void resize(unsigned N) { ValuePtrs.resize(N); }
void push_back(Value *V) { ValuePtrs.emplace_back(V); }
void clear() {
assert(ResolveConstants.empty() && "Constants not resolved?");
ValuePtrs.clear();
}
Value *operator[](unsigned i) const {
assert(i < ValuePtrs.size());
return ValuePtrs[i];
}
Value *back() const { return ValuePtrs.back(); }
void pop_back() { ValuePtrs.pop_back(); }
bool empty() const { return ValuePtrs.empty(); }
void shrinkTo(unsigned N) {
assert(N <= size() && "Invalid shrinkTo request!");
ValuePtrs.resize(N);
}
Constant *getConstantFwdRef(unsigned Idx, Type *Ty);
Value *getValueFwdRef(unsigned Idx, Type *Ty);
void assignValue(Value *V, unsigned Idx);
/// Once all constants are read, this method bulk resolves any forward
/// references.
void resolveConstantForwardRefs();
};
} // end namespace llvm
#endif // LLVM_LIB_BITCODE_READER_VALUELIST_H
......@@ -38,11 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "AdaptorOCL/OCL/BuiltinResource.h"
#include "AdaptorOCL/OCL/TB/igc_tb.h"
#if LLVM_VERSION_MAJOR == 4
#include "AdaptorOCL/Upgrader/llvm4/Upgrader.h"
#elif LLVM_VERSION_MAJOR == 7
#include "AdaptorOCL/Upgrader/llvm7/Upgrader.h"
#endif
#include "AdaptorOCL/Upgrader/Upgrader.h"
#include "AdaptorOCL/UnifyIROCL.hpp"
#include "AdaptorOCL/DriverInfoOCL.hpp"
......
......@@ -3241,6 +3241,15 @@ set(IGC_BUILD__LLVM_STATIC_LIBS_TO_LINK
"LLVMSupport"
"LLVMDemangle"
)
if(LLVM_VERSION_MAJOR EQUAL 8)
set(IGC_BUILD__LLVM_STATIC_LIBS_TO_LINK
"${IGC_BUILD__LLVM_STATIC_LIBS_TO_LINK}"
"LLVMInstCombine"
)
endif()
if(TARGET LLVMCore)
# LLVM targets have been already defined.
......
......@@ -366,7 +366,7 @@ bool AdvCodeMotion::hoistMost(bool InvPred, BasicBlock *IfBB,
Pos = &Lower->front();
for (auto BI = Exit->begin(), BE = Exit->end(); BI != BE; /*EMPTY*/) {
Instruction *Inst = &*BI++;
if (isa<TerminatorInst>(Inst))
if (Inst->isTerminator())
break;
Inst->moveBefore(Pos);
}
......
......@@ -1109,7 +1109,7 @@ CVariable* CoalescingEngine::PrepareExplicitPayload(
//Check for EOT payload.
if (payloadCovered) {
if (TerminatorInst * terminator = inst->getParent()->getTerminator())
if (IGCLLVM::TerminatorInst * terminator = inst->getParent()->getTerminator())
{
if (terminator != &(*terminator->getParent()->begin()))
{
......
......@@ -387,7 +387,7 @@ bool CodeSinking::ProcessBlock(BasicBlock &blk)
prevLoca = inst;
}
// intrinsic like discard has no explict use, gets skipped here
else if (isa<DbgInfoIntrinsic>(inst) || isa<TerminatorInst>(inst) ||
else if (isa<DbgInfoIntrinsic>(inst) || inst->isTerminator() ||
isa<PHINode>(inst) || inst->use_empty() )
{
prevLoca = inst;
......
......@@ -169,7 +169,7 @@ uint EmitPass::DecideInstanceAndSlice(llvm::BasicBlock &blk, SDAG &sdag, bool &s
numInstance = 1;
slicing = false;
}
else if (isa<TerminatorInst>(sdag.m_root))
else if (sdag.m_root->isTerminator())
{
numInstance = 1;
slicing = false;
......@@ -870,7 +870,7 @@ bool EmitPass::isCandidateIfStmt(
}
llvm::BasicBlock *S0 = Br->getSuccessor(0), *S1 = Br->getSuccessor(1);
llvm::TerminatorInst *T0 = S0->getTerminator(), *T1 = S1->getTerminator();
IGCLLVM::TerminatorInst *T0 = S0->getTerminator(), *T1 = S1->getTerminator();
assert(T1 && T0 && "BB is missing a terminator!");
bool isMatch =
S0->getSinglePredecessor() == ifBB && S1->getSinglePredecessor() == ifBB &&
......@@ -902,7 +902,7 @@ void EmitPass::MovPhiSources(llvm::BasicBlock* aBB)
std::vector<std::pair<CVariable*, CVariable*>> emitList;
std::map<CVariable*, unsigned int> dstVTyMap;
llvm::BasicBlock *bb = aBB;
llvm::TerminatorInst *TI = aBB->getTerminator();
IGCLLVM::TerminatorInst *TI = aBB->getTerminator();
assert(TI);
if (IGC_IS_FLAG_ENABLED(EnableOptimPhiMov))
......@@ -955,7 +955,7 @@ void EmitPass::MovPhiSources(llvm::BasicBlock* aBB)
else if (TI->getNumSuccessors() == 2 && isCandidateIfStmt(bb, otherBB, emptyBB))
{
// Check if this bb is the BB ("ifBB") that all phi-mov's are relocated to.
llvm::TerminatorInst *T0 = emptyBB->getTerminator();
IGCLLVM::TerminatorInst *T0 = emptyBB->getTerminator();
assert(T0->getNumSuccessors() == 1 && "Something wrong in if-then-else pattern!");
llvm::BasicBlock *phiB = T0->getSuccessor(0);
if (canRelocatePhiMov(otherBB, emptyBB, phiB))
......
......@@ -37,10 +37,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.