[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 01:12:29 PDT 2024


================
@@ -1902,16 +1902,18 @@ class IRBuilderBase {
   }
 
   Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
-                            const Twine &Name = "") {
+                            const Twine &Name = "",
+                            GEPNoWrapFlags NWFlags = GEPNoWrapFlags::none()) {
     Value *Idxs[] = {
       ConstantInt::get(Type::getInt32Ty(Context), Idx0),
       ConstantInt::get(Type::getInt32Ty(Context), Idx1)
     };
 
-    if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, GEPNoWrapFlags::none()))
+    if (auto *V =
+            Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/NWFlags.isInBounds()))
----------------
nikic wrote:

Shouldn't this be?
```suggestion
            Folder.FoldGEP(Ty, Ptr, Idxs, NWFlags))
```


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


More information about the cfe-commits mailing list