Skip to content

Commit ff57226

Browse files
bokrzesiigcbot
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
1 parent 16311e1 commit ff57226

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
@@ -768,6 +768,11 @@ class LLVMContextWrapper : public llvm::LLVMContext {
768768
llvm::SmallVector<llvm::StructType *, 16> m_allLayoutStructTypes;
769769
void AddRef();
770770
void Release();
771+
772+
// TODO: Remove after switch to LLVM 16 opque pointers.
773+
// In order to get rid of `Reapply_hasSetOpaquePointersValue.patch` patch, we're implementing
774+
// check if pointer type was set in IGC.
775+
bool IGC_IsPointerModeAlreadySet = false;
771776
};
772777

773778
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
// With LLVM 14, we invoke a proper check for the -opaque-pointers CL
@@ -36,11 +36,16 @@ inline bool canOverwriteLLVMCtxPtrMode(llvm::LLVMContext *Ctx) {
3636
// override this when opaque pointers are force-enabled in experimental
3737
// mode.
3838
return Ctx->supportsTypedPointers();
39-
#elif LLVM_VERSION_MAJOR >= 15
39+
#elif LLVM_VERSION_MAJOR == 15
4040
// With LLVM 15-16, we should not trigger CL option evaluation, as the
4141
// OPs mode will then get set as a permanent default. The only
4242
// alternative is to use an API below, non-native for LLVM 16.
4343
return !Ctx->hasSetOpaquePointersValue();
44+
#elif LLVM_VERSION_MAJOR >= 16
45+
// LLVM 16: we start removing switching between typed/opaque ptrs mode
46+
// In order to prepare for full move to the opaque pointers.
47+
// The first step is to get rid of .patches related to opaque pointers mode.
48+
return !IGC_IsPointerModeAlreadySet;
4449
#endif // LLVM_VERSION_MAJOR
4550
}
4651
} // 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)