Skip to content

Commit fb6814d

Browse files
matborzyszkowskiigcbot
authored andcommitted
Fix builds for Interim mode
Add `IGC_LLVM_TRUNK_REVISION` to llvmWrapper for Interim mode.
1 parent a1055b5 commit fb6814d

File tree

11 files changed

+73
-55
lines changed

11 files changed

+73
-55
lines changed

IGC/AdaptorCommon/RayTracing/DynamicRayManagementPass.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SPDX-License-Identifier: MIT
1919
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
2020
#include <llvm/Transforms/Utils/SSAUpdater.h>
2121
#include "common/LLVMWarningsPop.hpp"
22+
#include "llvmWrapper/Analysis/InstructionSimplify.h"
2223

2324
using namespace IGC;
2425
using namespace llvm;
@@ -517,11 +518,7 @@ bool DynamicRayManagementPass::TryProceedBasedApproach(Function& F)
517518
Value* flag = I->getOperand(0);
518519
if (auto* flagAsBinOp = dyn_cast<BinaryOperator>(flag))
519520
flag =
520-
#if LLVM_VERSION_MAJOR >= 15
521-
simplifyBinOp(
522-
#else
523-
SimplifyBinOp(
524-
#endif
521+
IGCLLVM::simplifyBinOp(
525522
flagAsBinOp->getOpcode(),
526523
flagAsBinOp->getOperand(0),
527524
flagAsBinOp->getOperand(1),

IGC/CMakeLists.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,25 @@ set(IGC_BUILD__PROJ_NAME_PREFIX "")
409409
set(IGC_BUILD__SPIRV_ENABLED ON)
410410

411411

412+
set(IGC_OPTION__LLVM_INTERIM OFF CACHE BOOL "Configure IGC to build with a provisional LLVM revision")
413+
message(STATUS "[IGC] IGC_OPTION__LLVM_INTERIM = ${IGC_OPTION__LLVM_INTERIM}")
414+
415+
# Recognize if we need to use LLVM interim mode and set appropriate definition
416+
if (IGC_OPTION__LLVM_INTERIM)
417+
# Switch on IGC_BUILD_LLVM_INTERIM when -DIGC_OPTION__LLVM_INTERIM=1 option is provided for locally build
418+
set(IGC_BUILD_LLVM_INTERIM ON)
419+
elseif($ENV{IGC_LLVM_INTERIM})
420+
# Switch on IGC_BUILD_LLVM_INTERIM when IGC_LLVM_INTERIM is set in environment e.g. yaml file
421+
set(IGC_BUILD_LLVM_INTERIM ON)
422+
endif()
423+
424+
if(IGC_BUILD_LLVM_INTERIM)
425+
message(STATUS "[IGC] IGC_BUILD_LLVM_INTERIM = ${IGC_BUILD_LLVM_INTERIM}")
426+
add_compile_definitions(IGC_LLVM_TRUNK_REVISION)
427+
# Temporary disable VC for Interim
428+
set(IGC_BUILD__VC_ENABLED OFF)
429+
endif()
430+
412431
# Enable vector compiler for Linux and Windows
413432
# If user already defined this, honor decision
414433
if(NOT DEFINED IGC_BUILD__VC_ENABLED)
@@ -1497,23 +1516,6 @@ add_subdirectory(common)
14971516
igc_sg_define(IGC__common)
14981517
igc_sg_define(IGC__Common_CLElfLib)
14991518

1500-
set(IGC_OPTION__LLVM_INTERIM OFF CACHE BOOL "Configure IGC to build with a provisional LLVM revision")
1501-
message(STATUS "[IGC] IGC_OPTION__LLVM_INTERIM = ${IGC_OPTION__LLVM_INTERIM}")
1502-
1503-
# Recognize if we need to use LLVM interim mode and set appropriate definition
1504-
if (IGC_OPTION__LLVM_INTERIM)
1505-
# Switch on IGC_BUILD_LLVM_INTERIM when -DIGC_OPTION__LLVM_INTERIM=1 option is provided for locally build
1506-
set(IGC_BUILD_LLVM_INTERIM ON)
1507-
elseif($ENV{IGC_LLVM_INTERIM})
1508-
# Switch on IGC_BUILD_LLVM_INTERIM when IGC_LLVM_INTERIM is set in environment e.g. yaml file
1509-
set(IGC_BUILD_LLVM_INTERIM ON)
1510-
endif()
1511-
1512-
if(IGC_BUILD_LLVM_INTERIM)
1513-
message(STATUS "[IGC] IGC_BUILD_LLVM_INTERIM = ${IGC_BUILD_LLVM_INTERIM}")
1514-
add_compile_definitions(IGC_LLVM_TRUNK_REVISION)
1515-
endif()
1516-
15171519

15181520
# Add protobuf
15191521
include(igc_find_protobuf)

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature
507507
if (IGC_IS_FLAG_ENABLED(allowLICM) && ctx.m_retryManager.AllowLICM())
508508
{
509509
mpm.add(createSpecialCasesDisableLICM());
510-
#if LLVM_VERSION_MAJOR >= 14
510+
#if !defined(IGC_LLVM_TRUNK_REVISION)
511511
mpm.add(llvm::createLICMPass(100, 500, true));
512512
#else
513-
mpm.add(llvm::createLICMPass());
513+
mpm.add(llvm::createLICMPass(100, 500));
514514
#endif
515515
}
516516
mpm.add(llvm::createLoopSimplifyPass());
@@ -901,10 +901,10 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature
901901
if (!fastCompile && !highAllocaPressure && !isPotentialHPCKernel && IGC_IS_FLAG_ENABLED(allowLICM) && ctx.m_retryManager.AllowLICM())
902902
{
903903
mpm.add(createSpecialCasesDisableLICM());
904-
#if LLVM_VERSION_MAJOR >= 14
904+
#if !defined(IGC_LLVM_TRUNK_REVISION)
905905
mpm.add(llvm::createLICMPass(100, 500, true));
906906
#else
907-
mpm.add(llvm::createLICMPass());
907+
mpm.add(llvm::createLICMPass(100, 500));
908908
#endif
909909
mpm.add(llvm::createEarlyCSEPass());
910910
}
@@ -1510,10 +1510,10 @@ void OptimizeIR(CodeGenContext* const pContext)
15101510
mpm.add(createSpecialCasesDisableLICM());
15111511
int licmTh = IGC_GET_FLAG_VALUE(LICMStatThreshold);
15121512
mpm.add(new InstrStatistic(pContext, LICM_STAT, InstrStatStage::BEGIN, licmTh));
1513-
#if LLVM_VERSION_MAJOR >= 14
1513+
#if !defined(IGC_LLVM_TRUNK_REVISION)
15141514
mpm.add(llvm::createLICMPass(100, 500, true));
15151515
#else
1516-
mpm.add(llvm::createLICMPass());
1516+
mpm.add(llvm::createLICMPass(100, 500));
15171517
#endif
15181518
mpm.add(new InstrStatistic(pContext, LICM_STAT, InstrStatStage::END, licmTh));
15191519
}
@@ -1581,10 +1581,10 @@ void OptimizeIR(CodeGenContext* const pContext)
15811581
if (allowLICM)
15821582
{
15831583
mpm.add(createSpecialCasesDisableLICM());
1584-
#if LLVM_VERSION_MAJOR >= 14
1584+
#if !defined(IGC_LLVM_TRUNK_REVISION)
15851585
mpm.add(llvm::createLICMPass(100, 500, true));
15861586
#else
1587-
mpm.add(llvm::createLICMPass());
1587+
mpm.add(llvm::createLICMPass(100, 500));
15881588
#endif
15891589
}
15901590

IGC/WrapperLLVM/include/llvmWrapper/ADT/APInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace IGCLLVM {
2020
#if LLVM_VERSION_MAJOR >= 14
2121
using SignedDivisionByConstantInfo = llvm::SignedDivisionByConstantInfo;
2222
using UnsignedDivisionByConstantInfo =
23-
#if LLVM_VERSION_MAJOR == 14
23+
#if (LLVM_VERSION_MAJOR == 14) || defined(IGC_LLVM_TRUNK_REVISION)
2424
// Account for a typo
2525
llvm::UnsignedDivisonByConstantInfo;
2626
#else // LLVM_VERSION_MAJOR == 14

IGC/WrapperLLVM/include/llvmWrapper/Analysis/InstructionSimplify.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,33 @@ SPDX-License-Identifier: MIT
1414

1515
namespace IGCLLVM
1616
{
17-
#if LLVM_VERSION_MAJOR >= 15
18-
using llvm::simplifyInstruction;
19-
#else
17+
#if (LLVM_VERSION_MAJOR < 15) || defined (IGC_LLVM_TRUNK_REVISION)
2018
inline llvm::Value* simplifyInstruction(
2119
llvm::Instruction* I, const llvm::SimplifyQuery& Q,
2220
llvm::OptimizationRemarkEmitter* ORE = nullptr) {
2321
return llvm::SimplifyInstruction(I, Q, ORE);
2422
}
23+
#else
24+
using llvm::simplifyInstruction;
25+
#endif
26+
27+
#if (LLVM_VERSION_MAJOR < 15) || defined (IGC_LLVM_TRUNK_REVISION)
28+
inline llvm::Value* simplifyBinOp(
29+
unsigned Opcode, llvm::Value* LHS, llvm::Value* RHS,
30+
const llvm::SimplifyQuery& Q) {
31+
return llvm::SimplifyBinOp(Opcode, LHS, RHS, Q);
32+
}
33+
#else
34+
using llvm::simplifyBinOp;
35+
#endif
36+
37+
#if (LLVM_VERSION_MAJOR < 15) || defined (IGC_LLVM_TRUNK_REVISION)
38+
inline llvm::Value* simplifyCall(
39+
llvm::CallBase* Call, const llvm::SimplifyQuery& Q) {
40+
return llvm::SimplifyCall(Call, Q);
41+
}
42+
#else
43+
using llvm::simplifyCall;
2544
#endif
2645
}
2746

IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFold.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT
1111

1212
#include "llvm/Config/llvm-config.h"
1313
#include "llvm/IR/Constants.h"
14-
#if LLVM_VERSION_MAJOR >= 15
14+
#if (LLVM_VERSION_MAJOR >= 15) && !defined(IGC_LLVM_TRUNK_REVISION)
1515
#include "llvm/IR/ConstantFold.h"
1616
#endif
1717

@@ -20,7 +20,7 @@ namespace IGCLLVM
2020
inline llvm::Constant* ConstantFoldExtractValueInstruction(
2121
llvm::Constant* Agg, llvm::ArrayRef<unsigned> Idxs,
2222
llvm::Type* OnlyIfReducedTy = nullptr) {
23-
#if LLVM_VERSION_MAJOR < 15
23+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
2424
return llvm::ConstantExpr::getExtractValue(Agg, Idxs, OnlyIfReducedTy);
2525
#else
2626
return llvm::ConstantFoldExtractValueInstruction(Agg, Idxs);
@@ -30,7 +30,7 @@ namespace IGCLLVM
3030
inline llvm::Constant* ConstantFoldInsertValueInstruction(
3131
llvm::Constant* Agg, llvm::Constant* Val,
3232
llvm::ArrayRef<unsigned> Idxs, llvm::Type* OnlyIfReducedTy = nullptr) {
33-
#if LLVM_VERSION_MAJOR < 15
33+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
3434
return llvm::ConstantExpr::getInsertValue(
3535
Agg, Val, Idxs, OnlyIfReducedTy);
3636
#else
@@ -40,7 +40,7 @@ namespace IGCLLVM
4040

4141
inline llvm::Constant* ConstantFoldBinaryInstruction(
4242
unsigned Opcode, llvm::Constant* V1, llvm::Constant* V2) {
43-
#if LLVM_VERSION_MAJOR < 15
43+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
4444
// TODO: Add other opcodes as needed
4545
switch (Opcode) {
4646
case llvm::Instruction::SDiv:

IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFolder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace IGCLLVM
104104
/// up to LLVM 14.
105105
/// -------------------------------------------------------------------
106106

107-
#if LLVM_VERSION_MAJOR < 15
107+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
108108

109109
// Note: for direct usage in code, prefer `CreateBinOp` wrapper for all
110110
// LLVM versions up to 15.
@@ -283,14 +283,14 @@ namespace IGCLLVM
283283
llvm::ArrayRef<unsigned> IdxList) const override {
284284
return m_baseConstantFolder.CreateInsertValue(Agg, Val, IdxList);
285285
}
286-
#endif // LLVM_VERSION_MAJOR < 15
286+
#endif // (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
287287

288288
/// -------------------------------------------------------------------
289289
/// This block defines virtual methods that are present in the base
290290
/// llvm::IRBuilderFolder class starting from LLVM 15.
291291
/// -------------------------------------------------------------------
292292

293-
#if LLVM_VERSION_MAJOR >= 15
293+
#if (LLVM_VERSION_MAJOR >= 15) && !defined(IGC_LLVM_TRUNK_REVISION)
294294
inline llvm::Value* FoldBinOp(llvm::Instruction::BinaryOps Opc,
295295
llvm::Value* LHS, llvm::Value* RHS) const override {
296296
return m_baseConstantFolder.FoldBinOp(Opc, LHS, RHS);
@@ -354,7 +354,7 @@ namespace IGCLLVM
354354

355355
inline llvm::Constant* CreateBinOp(llvm::Instruction::BinaryOps Opc,
356356
llvm::Constant* LHS, llvm::Constant* RHS) const
357-
#if LLVM_VERSION_MAJOR < 15
357+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
358358
override {
359359
return m_baseConstantFolder.CreateBinOp(Opc, LHS, RHS);
360360
}

IGC/WrapperLLVM/include/llvmWrapper/IR/LLVMContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace IGCLLVM
1919
inline void setOpaquePointers(llvm::LLVMContext* Ctx, const bool Enable)
2020
{
2121
IGC_ASSERT_MESSAGE(Ctx, "Null LLVMContext pointer!");
22-
#if LLVM_VERSION_MAJOR == 14
22+
#if (LLVM_VERSION_MAJOR == 14) || defined(IGC_LLVM_TRUNK_REVISION)
2323
if (Enable)
2424
Ctx->enableOpaquePointers();
2525
#elif LLVM_VERSION_MAJOR >= 15
@@ -35,7 +35,7 @@ namespace IGC
3535
IGC_ASSERT_MESSAGE(Ctx, "Null LLVMContext pointer!");
3636
#if LLVM_VERSION_MAJOR < 14
3737
return false;
38-
#elif LLVM_VERSION_MAJOR == 14
38+
#elif (LLVM_VERSION_MAJOR == 14) || defined(IGC_LLVM_TRUNK_REVISION)
3939
// With LLVM 14, we invoke a proper check for the -opaque-pointers CL
4040
// option. Regardless of whether it's false by LLVM 14's default, or
4141
// through an explicit setting, we deem it acceptable for IGC to

IGC/WrapperLLVM/include/llvmWrapper/MC/MCStreamer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ inline void initSections(llvm::MCStreamer *streamer, bool NoExecStack, const llv
2323

2424
inline void switchSection(llvm::MCStreamer *streamer, llvm::MCSection *Section,
2525
const llvm::MCExpr *Subsection = nullptr) {
26-
#if LLVM_VERSION_MAJOR >= 15
27-
streamer->switchSection(Section, Subsection);
28-
#else
26+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
2927
streamer->SwitchSection(Section, Subsection);
28+
#else
29+
streamer->switchSection(Section, Subsection);
3030
#endif
3131
}
3232

3333
inline void finish(llvm::MCStreamer *streamer) {
34-
#if LLVM_VERSION_MAJOR >= 15
35-
streamer->finish();
36-
#else
34+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
3735
streamer->Finish();
36+
#else
37+
streamer->finish();
3838
#endif
3939
}
4040
}

IGC/WrapperLLVM/include/llvmWrapper/Target/TargetMachine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ SPDX-License-Identifier: MIT
1414
#include "llvm/Support/CodeGen.h"
1515
#include "llvm/Target/TargetMachine.h"
1616

17-
#if LLVM_VERSION_MAJOR < 15
17+
#if (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
1818
#define LLVM_GET_TTI_API_QUAL
19-
#else // LLVM_VERSION_MAJOR
19+
#else // (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
2020
#define LLVM_GET_TTI_API_QUAL const
21-
#endif // LLVM_VERSION_MAJOR
21+
#endif // (LLVM_VERSION_MAJOR < 15) || defined(IGC_LLVM_TRUNK_REVISION)
2222

2323
namespace IGCLLVM {
2424
#if LLVM_VERSION_MAJOR < 10

0 commit comments

Comments
 (0)