[PATCH] D138992: [DebugInfo][SROA] Correct debug info for global variables spanning multiple fragments in case of SROA

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 09:33:37 PST 2022


aprantl added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:432
     uint64_t CurVarSize = Var->getType()->getSizeInBits();
+    CurVarEndInBits = CurVarOffsetInBits + CurVarSize;
     // Current variable ends before start of fragment, ignore.
----------------
Why initialize to zero and then again here?


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:438
 
-    // Current variable fits in the fragment.
-    if (CurVarOffsetInBits == FragmentOffsetInBits &&
-        CurVarSize == FragmentSizeInBits)
-      Expr = DIExpression::get(Expr->getContext(), {});
-    // If the FragmentSize is smaller than the variable,
-    // emit a fragment expression.
-    else if (FragmentSizeInBits < VarSize) {
+    // If the FragmentSize is greater than or equal to the current variable.
+    if (CurVarSize != 0 && /* CurVarSize is known */
----------------
tbh, I found the original comment easier to understand


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:440
+    if (CurVarSize != 0 && /* CurVarSize is known */
+        CurVarOffsetInBits >= FragmentOffsetInBits &&
+        CurVarEndInBits <= FragmentEndInBits) {
----------------
Aren't these two conditions trivially true because of the check above?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138992/new/

https://reviews.llvm.org/D138992



More information about the llvm-commits mailing list