@@ -376,19 +376,24 @@ namespace IGC
376376 CreateResourceDimensionTypes (*this );
377377 }
378378 auto * basePtr = static_cast <llvm::LLVMContext*>(this );
379- // When opaque pointers are enabled through the environment setting, we
380- // expect the Context to convert any incoming typed pointers
381- // automatically. However, the build system has opaque pointers enabled
382- // in the FE/in the builtin bitcode, that setting gets force-enabled,
383- // as the context will only operate on opaque pointers anyway.
384- // TODO: For transition purposes, consider introducing an IGC internal
385- // option to tweak typed/opaque pointers with a precedence over the
386- // environment flag.
379+ // By default, LLVM 16+ operates on opaque pointers and older LLVM versions on typed pointers. The flag
380+ // EnableOpaquePointersBackend allows enabling opaque pointers on older LLVM versions and then any incoming
381+ // pointer types are dropped. The flag ForceTypedPointers enables us to force typed pointers on LLVM 16+
382+ // for maintenance purposes. It is not possible to ForceTypedPointers when any opaque pointers are present
383+ // in an LLVM IR module, then opaque pointer mode is force enabled. EnableOpaquePointersBackend does not
384+ // perform automatic conversion of builtin types which should be represented using TargetExtTy.
385+ // TODO: For transition purposes, consider introducing an IGC internal option to tweak typed/opaque pointers
386+ // with a precedence over the environment flag.
387387 if (IGC::canOverwriteLLVMCtxPtrMode (basePtr))
388388 {
389- IGCLLVM::setOpaquePointers (basePtr,
390- __IGC_OPAQUE_POINTERS_API_ENABLED ||
391- IGC_IS_FLAG_ENABLED (EnableOpaquePointersBackend));
389+ bool enableOpaquePointers = __IGC_OPAQUE_POINTERS_API_ENABLED || IGC_IS_FLAG_ENABLED (EnableOpaquePointersBackend);
390+
391+ if (ForceTypedPointers.getValue ())
392+ {
393+ enableOpaquePointers = false ;
394+ }
395+
396+ IGCLLVM::setOpaquePointers (basePtr, enableOpaquePointers);
392397 }
393398 }
394399
0 commit comments