[clang] [Clang][HLSL] Start emitting structured GEP instruction (PR #177332)
Steven Perron via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 26 06:40:54 PST 2026
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/177332 at github.com>
================
@@ -5521,6 +5545,14 @@ static Address emitAddrOfFieldStorage(CodeGenFunction &CGF, Address base,
unsigned idx =
CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
+ llvm::Type *StructType =
+ CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMType();
+
+ if (CGF.getLangOpts().HLSL && CGF.getLangOpts().EmitStructuredGEP)
+ return RawAddress(
+ CGF.Builder.CreateStructuredGEP(StructType, base.emitRawPointer(CGF),
----------------
s-perron wrote:
+1 to @Keenuts reply. For SPIR-V, we need the SGEP essentially all of the time. The way some optimizations rewrite GEPs make it impossible to generate valid OpAccessChain instructions in the backend. Recognizing when the optimizer may be able to transform the code in such a way is not the type of analysis we want to the FE to do.
https://github.com/llvm/llvm-project/pull/177332
More information about the cfe-commits
mailing list