Skip to content

Commit 09bdd4c

Browse files
aratajewigcbot
authored andcommitted
Remove InsertGenericPtrArithmeticMetadata pass
`InsertGenericPtrArithmeticMetadata` pass is responsible for adding `generic.arith` metadata to addrspacecast from {`private`, `local`, `global`} addrspace to `generic` addrspace. If it's present, then `EmitVISAPass` bypasses tagging a generic pointer while emitting the addrspacecast. The metadata gets added if `InsertGenericPtrArithmeticMetadata` pass detects that the addrspacecast's result is used for pointer arithmetic. Generic pointer tag can be problematic while comparing a generic pointer with `NULL` or with some named pointer {`private`, `local`, `global`}. However, in this case it's not necessary to depend on `generic.arith` metadata, because IGC has a pattern match that detects generic pointers comparison and resets tag bits if so. I don't see any reasonable arguments behind keeping the mechanism for `generic.arith` at the moment, therefore removing it. Precommit testing hasn't detected any functional regression on this change. Moreover, `generic.arith` may cause functional incorrectness. Here is the example: ```cpp __kernel void generic_ptr_issue(local int* p0, local ulong* p1) { generic int* p0_g = p0; // addrspacecast local -> generic ulong p0_g_addr_plus_4 = (ulong)p0_g + 4; // (not tagged due to generic.arith) p1[0] = p0_g_addr_plus_4; // untagged address written to local memory generic int* p0_g_plus_4 = (generic int*)p1[0]; // loading untagged address as generic p0_g_plus_4[0] = 5; // address is actually local, but global branch is taken due to a missing tag }; ```
1 parent 3788aab commit 09bdd4c

File tree

7 files changed

+0
-215
lines changed

7 files changed

+0
-215
lines changed

IGC/Compiler/CISACodeGen/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ set(IGC_BUILD__SRC__CISACodeGen_Common
4747
"${CMAKE_CURRENT_SOURCE_DIR}/getCacheOpts.cpp"
4848
"${CMAKE_CURRENT_SOURCE_DIR}/HalfPromotion.cpp"
4949
"${CMAKE_CURRENT_SOURCE_DIR}/HoistCongruentPhi.cpp"
50-
"${CMAKE_CURRENT_SOURCE_DIR}/InsertGenericPtrArithmeticMetadata.cpp"
5150
"${CMAKE_CURRENT_SOURCE_DIR}/LdShrink.cpp"
5251
"${CMAKE_CURRENT_SOURCE_DIR}/LiveVars.cpp"
5352
"${CMAKE_CURRENT_SOURCE_DIR}/LivenessAnalysis.cpp"
@@ -149,7 +148,6 @@ set(IGC_BUILD__HDR__CISACodeGen_Common
149148
"${CMAKE_CURRENT_SOURCE_DIR}/getCacheOpts.h"
150149
"${CMAKE_CURRENT_SOURCE_DIR}/HalfPromotion.h"
151150
"${CMAKE_CURRENT_SOURCE_DIR}/HoistCongruentPhi.hpp"
152-
"${CMAKE_CURRENT_SOURCE_DIR}/InsertGenericPtrArithmeticMetadata.hpp"
153151
"${CMAKE_CURRENT_SOURCE_DIR}/LdShrink.h"
154152
"${CMAKE_CURRENT_SOURCE_DIR}/LiveVars.hpp"
155153
"${CMAKE_CURRENT_SOURCE_DIR}/LivenessAnalysis.hpp"

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10021,14 +10021,6 @@ void EmitPass::emitAddrSpaceCast(llvm::AddrSpaceCastInst* addrSpaceCast)
1002110021
// Address space cast is in the form of {private, local, global} -> generic
1002210022
// A tag is added according to the address space of the source
1002310023

10024-
MDNode* genericMD = addrSpaceCast->getMetadata("generic.arith");
10025-
if (genericMD)
10026-
{
10027-
m_encoder->Cast(m_destination, srcV);
10028-
m_encoder->Push();
10029-
return;
10030-
}
10031-
1003210024
if (sourceAddrSpace == ADDRESS_SPACE_PRIVATE && (!m_pCtx->allocatePrivateAsGlobalBuffer() || m_pCtx->mustDistinguishBetweenPrivateAndGlobalPtr()))
1003310025
{
1003410026
emitAddrSpaceToGenericCast(addrSpaceCast, srcV, 1);

IGC/Compiler/CISACodeGen/InsertGenericPtrArithmeticMetadata.cpp

Lines changed: 0 additions & 100 deletions
This file was deleted.

IGC/Compiler/CISACodeGen/InsertGenericPtrArithmeticMetadata.hpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ SPDX-License-Identifier: MIT
5252
#include "Compiler/CISACodeGen/UniformAssumptions.hpp"
5353
#include "Compiler/CISACodeGen/VectorProcess.hpp"
5454
#include "Compiler/CISACodeGen/RuntimeValueLegalizationPass.h"
55-
#include "Compiler/CISACodeGen/InsertGenericPtrArithmeticMetadata.hpp"
5655
#include "Compiler/CISACodeGen/LowerGEPForPrivMem.hpp"
5756
#include "Compiler/CISACodeGen/POSH_RemoveNonPositionOutput.h"
5857
#include "Compiler/CISACodeGen/RegisterEstimator.hpp"
@@ -1107,10 +1106,6 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature
11071106

11081107
mpm.add(new WAFMinFMax());
11091108

1110-
// Preferred to be added after llvm instruction combining, otherwise 'generic.arith'
1111-
// metadata may get lost during optimizations.
1112-
mpm.add(new InsertGenericPtrArithmeticMetadata());
1113-
11141109
mpm.add(createTimeStatsCounterPass(&ctx, TIME_CG_Legalization, STATS_COUNTER_END));
11151110

11161111
COMPILER_TIME_END(&ctx, TIME_CG_Add_Legalization_Passes);

IGC/Compiler/InitializePasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ void initializeHandleLoadStoreInstructionsPass(llvm::PassRegistry&);
8989
void initializeIGCConstPropPass(llvm::PassRegistry&);
9090
void initializeJointMatrixFuncsResolutionPassPass(llvm::PassRegistry&);
9191
void initializeGatingSimilarSamplesPass(llvm::PassRegistry&);
92-
void initializeInsertGenericPtrArithmeticMetadataPass(llvm::PassRegistry&);
9392
void initializeImageFuncResolutionPass(llvm::PassRegistry&);
9493
void initializeImageFuncsAnalysisPass(llvm::PassRegistry&);
9594
void initializeImage3dToImage2darrayPass(llvm::PassRegistry&);

IGC/Compiler/tests/InsertGenericPtrArithmeticMetadata/basic.ll

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)