[clang] [Clang][HLSL] Start emitting structured GEP instruction (PR #177332)
Nathan Gauër via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 23 05:10:55 PST 2026
================
@@ -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),
----------------
Keenuts wrote:
I'm afraid doing this would cause issues on more complex codes: the SGEP gives us some guarantees around what optimizations can do. Emitting a GEP instead will allow optimizations to merge those and do normal pointer arithmetic. Seems to me that the simplest approach is to always emit. But maybe we'll see in the future that in some cases we can emit a GEP.
https://github.com/llvm/llvm-project/pull/177332
More information about the cfe-commits
mailing list