[clang] [NFC][HLSL] Remove useless GEP (PR #177584)

Steven Perron via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 23 06:03:38 PST 2026


================
@@ -1113,9 +1113,7 @@ static void initializeBuffer(CodeGenModule &CGM, llvm::GlobalVariable *GV,
       /*ReturnType=*/HandleTy, IntrID, Args, nullptr,
       Twine(GV->getName()).concat("_h"));
 
-  llvm::Value *HandleRef = Builder.CreateStructGEP(GV->getValueType(), GV, 0);
-  Builder.CreateAlignedStore(CreateHandle, HandleRef,
-                             HandleRef->getPointerAlignment(DL));
----------------
s-perron wrote:

It was not just that this is being folded away. `GV` is the target type for the cbuffer. See the assert on line 1110.  Doing a struct GEP on the target types is invalid. We do not see an error because the GEP is folded. Thanks for noticing this Nathan.

https://github.com/llvm/llvm-project/pull/177584


More information about the cfe-commits mailing list