Skip to content

Commit fb6f156

Browse files
Anton Sidorenkoigcbot
authored andcommitted
Enable trampoline insertion pass by default
TrampolineInsertion pass must be enabled by default to make VISA and binary linking possible.
1 parent 60e66b5 commit fb6f156

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

IGC/VectorCompiler/include/vc/Utils/GenX/KernelInfo.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ SPDX-License-Identifier: MIT
99
#ifndef VC_UTILS_GENX_KERNELINFO_H
1010
#define VC_UTILS_GENX_KERNELINFO_H
1111

12+
#include "vc/InternalIntrinsics/InternalIntrinsics.h"
1213
#include "vc/Utils/GenX/InternalMetadata.h"
14+
#include "vc/Utils/GenX/Intrinsics.h"
1315
#include "vc/Utils/GenX/RegCategory.h"
1416

1517
#include "Probe/Assertion.h"
@@ -88,13 +90,18 @@ inline bool isIndirect(const llvm::Function *F) {
8890
// structure types is fixed for intrinsics.
8991
if (llvm::GenXIntrinsic::isAnyNonTrivialIntrinsic(F))
9092
return false;
91-
// FIXME: The condition of which function is considered to be indirectly
92-
// called will be changed soon.
93-
bool IsIndirect = F->hasAddressTaken();
93+
if (vc::InternalIntrinsic::isInternalNonTrivialIntrinsic(F))
94+
return false;
95+
if (vc::isKernel(F))
96+
return false;
97+
if (vc::isEmulationFunction(*F))
98+
return false;
99+
if (!F->hasAddressTaken() && F->hasLocalLinkage())
100+
return false;
94101
IGC_ASSERT_MESSAGE(
95-
!IsIndirect || requiresStackCall(F),
102+
requiresStackCall(F),
96103
"The indirectly-called function is expected to be a stack call");
97-
return IsIndirect;
104+
return true;
98105
}
99106

100107
inline bool isIndirect(const llvm::Function &F) { return isIndirect(&F); }

IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5431,10 +5431,6 @@ void GenXKernelBuilder::buildInlineAsm(CallInst *CI) {
54315431
void GenXKernelBuilder::buildCall(CallInst *CI, const DstOpndDesc &DstDesc) {
54325432
LLVM_DEBUG(dbgs() << CI << "\n");
54335433
Function *Callee = CI->getCalledFunction();
5434-
IGC_ASSERT_MESSAGE(
5435-
!Callee || !Callee->isDeclaration(),
5436-
"Currently VC backend does not support modules with external functions");
5437-
54385434
if (!Callee || vc::requiresStackCall(Callee)) {
54395435
if (UseNewStackBuilder)
54405436
buildStackCallLight(CI, DstDesc);

IGC/VectorCompiler/lib/GenXCodeGen/GenXGlobalValueLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ void GenXGlobalValueLowering::fillWorkListForGVInstUse(Use &GVUse) {
208208
GenXIntrinsic::genx_gaddr,
209209
"llvm.gaddr must be inserted by this pass, but someone "
210210
"inserted it before");
211-
// Skipping direct calls. Relocating will make them indirect.
212-
if (isa<Function>(ConstWithGV) && isa<CallInst>(Usr) &&
213-
cast<CallInst>(Usr)->getCalledFunction() == cast<Function>(ConstWithGV))
214-
return;
211+
// Do not skip direct calls as an indirectly-called function can be called
212+
// only indirectly. See GenXTrampolineInsertion
215213
Function *Func = Usr->getParent()->getParent();
216214
WorkList[Func].Users.insert({Usr, GVUse.getOperandNo()});
217215
WorkList[Func].Replacement[ConstWithGV] = nullptr;

IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTrampolineInsertion.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SPDX-License-Identifier: MIT
5252

5353
#include "llvmWrapper/IR/Value.h"
5454
#include "vc/GenXOpts/GenXOpts.h"
55+
#include "vc/InternalIntrinsics/InternalIntrinsics.h"
5556
#include "vc/Support/BackendConfig.h"
5657
#include "vc/Utils/GenX/Intrinsics.h"
5758
#include "vc/Utils/GenX/KernelInfo.h"
@@ -67,7 +68,7 @@ using namespace llvm;
6768

6869
static cl::opt<bool> EnableTrampolineInsertion(
6970
"vc-enable-trampoline-insertion",
70-
llvm::cl::desc("Enable/disable GenXTrampolineInsertion"), cl::init(false),
71+
llvm::cl::desc("Enable/disable GenXTrampolineInsertion"), cl::init(true),
7172
cl::Hidden);
7273

7374
namespace {
@@ -99,6 +100,8 @@ class GenXTrampolineInsertion : public ModulePass,
99100
void GenXTrampolineInsertion::visitFunction(Function &F) {
100101
if (GenXIntrinsic::isAnyNonTrivialIntrinsic(&F))
101102
return;
103+
if (vc::InternalIntrinsic::isInternalNonTrivialIntrinsic(&F))
104+
return;
102105
if (vc::isEmulationFunction(F))
103106
return;
104107
if (vc::isKernel(&F))

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ DECLARE_IGC_GROUP("VectorCompiler Options")
767767
DECLARE_IGC_REGKEY(DWORD, VCNoOptFinalizerControl, 0, "Controls if finalizer is invoked with -debug flag", true)
768768
DECLARE_IGC_REGKEY(DWORD, VCDisableLRCoalescingControl, 0, "Controls if LR coalescing", true)
769769
DECLARE_IGC_REGKEY(DWORD, VCDisableExtraCoalescing, 0, "Disable extra coalescing", true)
770-
DECLARE_IGC_REGKEY(bool, VCSaveStackCallLinkage, false,
770+
DECLARE_IGC_REGKEY(bool, VCSaveStackCallLinkage, true,
771771
"Do not override stack calls linkage as internal", true)
772772
DECLARE_IGC_REGKEY(bool, VCDirectCallsOnly, false, "Generate code under the assumption all unknown calls are direct", true)
773773
DECLARE_IGC_REGKEY(DWORD, VCLoopUnrollThreshold, 0, "Set the loop unroll threshold for VC. Value 0 will use the default threshold.", true)

0 commit comments

Comments
 (0)