Skip to content

Commit

Permalink
Drop LLVM 8 API wrappers
Browse files Browse the repository at this point in the history
Drop leftover wrappers from the llvmWrapper module, refactor call sites
accordingly. `llvm::createLoopUnrollPass()` API deserves special attention -
at the LLVM 8 times, the assumption had been that the signature may keep
changing with each new version, yet it's turned out not to be the case.
  • Loading branch information
AGindinson authored and igcbot committed Jul 24, 2023
1 parent 8357241 commit bc85f1a
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 100 deletions.
8 changes: 0 additions & 8 deletions IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,20 +583,12 @@ class SPIRVToLLVMDbgTran {
return type->getSizeInBits();
else if (auto DITy = dyn_cast_or_null<llvm::DIDerivedType>(type))
{
#if LLVM_VERSION_MAJOR == 8
auto baseType = DITy->getBaseType().resolve();
#else
auto baseType = DITy->getBaseType();
#endif
return getSizeInBits(baseType);
}
else if (auto CTy = dyn_cast_or_null<llvm::DICompositeType>(type))
{
#if LLVM_VERSION_MAJOR == 8
auto baseType = CTy->getBaseType().resolve();
#else
auto baseType = CTy->getBaseType();
#endif
return getSizeInBits(baseType);
}

Expand Down
14 changes: 9 additions & 5 deletions IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ SPDX-License-Identifier: MIT
#include <llvm/Transforms/IPO/FunctionAttrs.h>
#include <llvm/Transforms/Utils.h>
#include <llvm/Transforms/Scalar/InstSimplifyPass.h>
#include <llvmWrapper/Transforms/Scalar.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Bitcode/BitcodeWriter.h>
#include <llvm/Transforms/InstCombine/InstCombine.h>
#include "common/LLVMWarningsPop.hpp"
Expand Down Expand Up @@ -440,7 +440,8 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature

if (LoopUnrollThreshold > 0 && (ctx.m_tempCount < 64))
{
mpm.add(IGCLLVM::createLoopUnrollPass(2, LoopUnrollThreshold, -1, 1));
mpm.add(llvm::createLoopUnrollPass(2, false, false,
LoopUnrollThreshold, -1, 1, -1, -1, -1));
}

mpm.add(createBarrierNoopPass());
Expand Down Expand Up @@ -1411,7 +1412,8 @@ void OptimizeIR(CodeGenContext* const pContext)
!disableLoopUnrollStage1)
|| hasIndexTemp)
{
mpm.add(IGCLLVM::createLoopUnrollPass());
mpm.add(llvm::createLoopUnrollPass(2, false, false, -1, -1,
-1, -1, -1, -1));
}

// Due to what looks like a bug in LICM, we need to break the LoopPassManager between
Expand All @@ -1427,7 +1429,8 @@ void OptimizeIR(CodeGenContext* const pContext)
// Second unrolling with the same threshold.
if (LoopUnrollThreshold > 0 && !IGC_IS_FLAG_ENABLED(DisableLoopUnroll))
{
mpm.add(IGCLLVM::createLoopUnrollPass());
mpm.add(llvm::createLoopUnrollPass(2, false, false, -1, -1,
-1, -1, -1, -1));
}

mpm.add(llvm::createLoopLoadEliminationPass());
Expand Down Expand Up @@ -1596,7 +1599,8 @@ void OptimizeIR(CodeGenContext* const pContext)
!disableLoopUnrollStage1)
|| hasIndexTemp)
{
mpm.add(IGCLLVM::createLoopUnrollPass());
mpm.add(llvm::createLoopUnrollPass(2, false, false, -1, -1,
-1, -1, -1, -1));
}
}

Expand Down
4 changes: 2 additions & 2 deletions IGC/Compiler/CustomLoopOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: MIT
#include "common/LLVMWarningsPush.hpp"
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
#include <llvmWrapper/Transforms/Utils/LoopUtils.h>
#include <llvm/Transforms/Utils/LoopUtils.h>
#include "common/LLVMWarningsPop.hpp"
#include "common/LLVMUtils.h"
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
Expand Down Expand Up @@ -882,7 +882,7 @@ bool LoopCanonicalization::processOneLoop(Loop* L, DominatorTree* DT, LoopInfo*
// Does the loop already have a preheader? If so, don't insert one.
BasicBlock* Preheader = L->getLoopPreheader();
if (!Preheader) {
Preheader = IGCLLVM::InsertPreheaderForLoop(L, DT, LI, PreserveLCSSA);
Preheader = InsertPreheaderForLoop(L, DT, LI, nullptr, PreserveLCSSA);
if (Preheader) {
changed = true;
}
Expand Down
2 changes: 1 addition & 1 deletion IGC/Compiler/Legalizer/InstExpander.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT

#include "TypeLegalizer.h"
#include "common/LLVMWarningsPush.hpp"
#include "llvmWrapper/IR/InstVisitor.h"
#include "llvm/IR/InstVisitor.h"
#include "common/LLVMWarningsPop.hpp"

namespace IGC {
Expand Down
2 changes: 1 addition & 1 deletion IGC/Compiler/Legalizer/InstLegalChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SPDX-License-Identifier: MIT
#include "TypeLegalizer.h"
#include "common/LLVMWarningsPush.hpp"
#include "llvm/Config/llvm-config.h"
#include "llvmWrapper/IR/InstVisitor.h"
#include "llvm/IR/InstVisitor.h"
#include "common/LLVMWarningsPop.hpp"

namespace IGC {
Expand Down
2 changes: 1 addition & 1 deletion IGC/Compiler/Legalizer/InstPromoter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT

#include "TypeLegalizer.h"
#include "common/LLVMWarningsPush.hpp"
#include "llvmWrapper/IR/InstVisitor.h"
#include "llvm/IR/InstVisitor.h"
#include "common/LLVMWarningsPop.hpp"

namespace IGC {
Expand Down
2 changes: 1 addition & 1 deletion IGC/Compiler/Legalizer/InstScalarizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT

#include "TypeLegalizer.h"
#include "common/LLVMWarningsPush.hpp"
#include "llvmWrapper/IR/InstVisitor.h"
#include "llvm/IR/InstVisitor.h"
#include "common/LLVMWarningsPop.hpp"

namespace IGC {
Expand Down
6 changes: 2 additions & 4 deletions IGC/PCH/llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ SPDX-License-Identifier: MIT
#include "llvm/IR/GVMaterializer.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LegacyPassManager.h"
Expand Down Expand Up @@ -191,6 +192,7 @@ SPDX-License-Identifier: MIT
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/InstSimplifyPass.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/FunctionComparator.h"
Expand Down Expand Up @@ -220,7 +222,6 @@ SPDX-License-Identifier: MIT
#include "llvmWrapper/IR/Function.h"
#include "llvmWrapper/IR/InstrTypes.h"
#include "llvmWrapper/IR/Instructions.h"
#include "llvmWrapper/IR/InstVisitor.h"
#include "llvmWrapper/IR/IntrinsicInst.h"
#include "llvmWrapper/IR/Intrinsics.h"
#include "llvmWrapper/IR/IRBuilder.h"
Expand All @@ -244,7 +245,6 @@ SPDX-License-Identifier: MIT
#include "llvmWrapper/Support/YAMLParser.h"
#include "llvmWrapper/Target/TargetMachine.h"
#include "llvmWrapper/Transforms/InstCombine/InstCombineWorklist.h"
#include "llvmWrapper/Transforms/Scalar.h"
#include "llvmWrapper/Transforms/Utils/Cloning.h"
#include "llvmWrapper/Transforms/Utils/Local.h"
#include "llvmWrapper/Transforms/Utils/LoopUtils.h"
Expand Down Expand Up @@ -282,7 +282,6 @@ SPDX-License-Identifier: MIT
// #include "llvm/IR/GlobalValue.h" - uses llvmWrapper
// #include "llvm/IR/InstrTypes.h" - uses llvmWrapper
// #include "llvm/IR/Instructions.h" - uses llvmWrapper
// #include "llvm/IR/InstVisitor.h" - uses llvmWrapper
// #include "llvm/IR/IntrinsicInst.h" - uses llvmWrapper
// #include "llvm/IR/Intrinsics.h" - uses llvmWrapper
// #include "llvm/IR/IRBuilder.h" - uses llvmWrapper
Expand All @@ -303,7 +302,6 @@ SPDX-License-Identifier: MIT
// #include "llvm/Support/SystemUtils.h" - uses llvmWrapper
// #include "llvm/Target/TargetMachine.h" - uses llvmWrapper
// #include "llvm/Transforms/InstCombine/InstCombineWorklist.h" - uses llvmWrapper
// #include "llvm/Transforms/Scalar.h" - uses llvmWrapper
// #include "llvm/Transforms/Utils/Cloning.h" - uses llvmWrapper
// #include "llvm/Transforms/Utils/Local.h" - uses llvmWrapper
// #include "llvm/Transforms/Utils/LoopUtils.h" - uses llvmWrapper
Expand Down
2 changes: 0 additions & 2 deletions IGC/WrapperLLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ set(IGC_WrapperLLVM_HDR
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/Function.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/InstrTypes.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/Instructions.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/InstVisitor.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/IntrinsicInst.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/Intrinsics.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/IR/IRBuilder.h"
Expand All @@ -62,7 +61,6 @@ set(IGC_WrapperLLVM_HDR
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Support/YAMLParser.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Target/TargetMachine.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/InstCombine/InstCombineWorklist.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Utils/Cloning.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Utils/LoopUtils.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Utils/Local.h"
Expand Down
23 changes: 0 additions & 23 deletions IGC/WrapperLLVM/include/llvmWrapper/IR/InstVisitor.h

This file was deleted.

8 changes: 4 additions & 4 deletions IGC/WrapperLLVM/include/llvmWrapper/IR/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ SPDX-License-Identifier: MIT

namespace IGCLLVM
{
#if LLVM_VERSION_MAJOR == 8
using llvm::Module;
#else
// TODO: Clean up obsolete uses at call sites
class Module : public llvm::Module
{
public:
Module(llvm::StringRef ModuleID, llvm::LLVMContext& C)
: llvm::Module(ModuleID, C)
{}

// TODO: Delete getOrInsertFunction wrappers
inline llvm::Value* getOrInsertFunction(llvm::StringRef Name, llvm::FunctionType *Ty)
{
return llvm::Module::getOrInsertFunction(Name, Ty).getCallee();
Expand All @@ -36,6 +35,7 @@ namespace IGCLLVM
return llvm::Module::getOrInsertFunction(Name, Ty, attributeList).getCallee();
}

// TODO: Refactor to use the LLVM 12+ signature at call sites
inline llvm::StructType* getTypeByName(llvm::StringRef Name)
{
#if LLVM_VERSION_MAJOR < 12
Expand All @@ -46,8 +46,8 @@ namespace IGCLLVM
}

};
#endif

// TODO: Refactor to use the LLVM 12+ signature at call sites
inline llvm::StructType *getTypeByName(llvm::Module &M, llvm::StringRef Name)
{
#if LLVM_VERSION_MAJOR < 12
Expand Down
38 changes: 0 additions & 38 deletions IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h

This file was deleted.

10 changes: 0 additions & 10 deletions IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ SPDX-License-Identifier: MIT

namespace IGCLLVM
{
#if LLVM_VERSION_MAJOR == 8
using llvm::InsertPreheaderForLoop;
#else
inline llvm::BasicBlock *InsertPreheaderForLoop(llvm::Loop *L, llvm::DominatorTree *DT, llvm::LoopInfo *LI,
bool PreserveLCSSA)
{
return llvm::InsertPreheaderForLoop(L, DT, LI, nullptr, PreserveLCSSA);
}
#endif

inline bool isInnermost(llvm::Loop *L) {
#if LLVM_VERSION_MAJOR >= 12
return L->isInnermost();
Expand Down

0 comments on commit bc85f1a

Please sign in to comment.