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

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 03:42:47 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:

It looks like this one still passes `NWFlags.isInBounds()` instead of the full `NWFlags`?

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


More information about the cfe-commits mailing list