Skip to content

Commit a1b485d

Browse files
bokrzesipszymich
authored andcommitted
[LLVM16] Removal of Reapply_hasSetOpaquePointersValue.patch
In order to reduce the amount of patches this PR moves check whether pointers mode was already set from LLVM to IGC More details in comments (cherry picked from commit ff57226)
1 parent 087f524 commit a1b485d

File tree

4 files changed

+26
-101
lines changed

4 files changed

+26
-101
lines changed

IGC/Compiler/CodeGenContext.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,22 @@ LLVMContextWrapper::LLVMContextWrapper(bool createResourceDimTypes) : m_UserAddr
312312
// perform automatic conversion of builtin types which should be represented using TargetExtTy.
313313
// TODO: For transition purposes, consider introducing an IGC internal option to tweak typed/opaque pointers
314314
// with a precedence over the environment flag.
315-
if (IGC::canOverwriteLLVMCtxPtrMode(basePtr)) {
316-
bool enableOpaquePointers = AreOpaquePointersEnabled();
317315

316+
// TODO: Remove/Re-evaluate once fully moved to the LLVM 16 opaque ptrs.
317+
// This WA_OpaquePointersCL flag is related to the same flag in LLVM itself
318+
// We're using it here to have consistent behaviour.
319+
// https://github.com/llvm/llvm-project/blob/release/16.x/llvm/lib/IR/LLVMContextImpl.cpp#L50
320+
auto WA_OpaquePointersCL = cl::getRegisteredOptions()["opaque-pointers"];
321+
if (WA_OpaquePointersCL && WA_OpaquePointersCL->getNumOccurrences() > 0) {
322+
IGC_IsPointerModeAlreadySet = true;
323+
}
324+
325+
if (IGC::canOverwriteLLVMCtxPtrMode(basePtr, IGC_IsPointerModeAlreadySet)) {
326+
bool enableOpaquePointers = AreOpaquePointersEnabled();
318327
IGCLLVM::setOpaquePointers(basePtr, enableOpaquePointers);
328+
IGC_IsPointerModeAlreadySet = true;
319329
}
330+
// TODO: end
320331
}
321332

322333
void LLVMContextWrapper::AddRef() { refCount++; }

IGC/Compiler/CodeGenPublic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,11 @@ class LLVMContextWrapper : public llvm::LLVMContext {
765765
llvm::SmallVector<llvm::StructType *, 16> m_allLayoutStructTypes;
766766
void AddRef();
767767
void Release();
768+
769+
// TODO: Remove after switch to LLVM 16 opque pointers.
770+
// In order to get rid of `Reapply_hasSetOpaquePointersValue.patch` patch, we're implementing
771+
// check if pointer type was set in IGC.
772+
bool IGC_IsPointerModeAlreadySet = false;
768773
};
769774

770775
struct RoutingIndex {

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2024 Intel Corporation
3+
Copyright (C) 2025 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -27,7 +27,7 @@ inline void setOpaquePointers(llvm::LLVMContext *Ctx, const bool Enable) {
2727
} // end namespace IGCLLVM
2828

2929
namespace IGC {
30-
inline bool canOverwriteLLVMCtxPtrMode(llvm::LLVMContext *Ctx) {
30+
inline bool canOverwriteLLVMCtxPtrMode(llvm::LLVMContext *Ctx, bool IGC_IsPointerModeAlreadySet) {
3131
IGC_ASSERT_MESSAGE(Ctx, "Null LLVMContext pointer!");
3232
#if LLVM_VERSION_MAJOR < 14
3333
return false;
@@ -38,11 +38,16 @@ inline bool canOverwriteLLVMCtxPtrMode(llvm::LLVMContext *Ctx) {
3838
// override this when opaque pointers are force-enabled in experimental
3939
// mode.
4040
return Ctx->supportsTypedPointers();
41-
#elif LLVM_VERSION_MAJOR >= 15
41+
#elif LLVM_VERSION_MAJOR == 15
4242
// With LLVM 15-16, we should not trigger CL option evaluation, as the
4343
// OPs mode will then get set as a permanent default. The only
4444
// alternative is to use an API below, non-native for LLVM 16.
4545
return !Ctx->hasSetOpaquePointersValue();
46+
#elif LLVM_VERSION_MAJOR >= 16
47+
// LLVM 16: we start removing switching between typed/opaque ptrs mode
48+
// In order to prepare for full move to the opaque pointers.
49+
// The first step is to get rid of .patches related to opaque pointers mode.
50+
return !IGC_IsPointerModeAlreadySet;
4651
#endif // LLVM_VERSION_MAJOR
4752
}
4853
} // end namespace IGC

external/llvm/releases/16.0.0/patches_external/Reapply_hasSetOpaquePointersValue.patch

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

0 commit comments

Comments
 (0)