[PATCH] D87641: [DebugInfo] Add assert for variable size when creating fragments.
Amy Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 15:30:54 PDT 2020
akhuang created this revision.
akhuang added reviewers: dblaikie, aprantl.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
akhuang requested review of this revision.
Recently I added the size to the debug info for class declarations, so
that the correct fragments are created when a class is not defined.
This patch asserts that the variable size exists when creating
fragments, since I think there shouldn't be any cases where we want to
create fragments for a variable with no size.t
Bug: https://bugs.llvm.org/show_bug.cgi?id=47338
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87641
Files:
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4534,15 +4534,14 @@
// The alloca may be larger than the variable.
auto VarSize = DbgDeclare->getVariable()->getSizeInBits();
- if (VarSize) {
- if (Size > *VarSize)
- Size = *VarSize;
- if (Size == 0 || Start + Size > *VarSize)
- continue;
- }
+ assert(VarSize && "Variable with fragments must have a size");
+ if (Size > *VarSize)
+ Size = *VarSize;
+ if (Size == 0 || Start + Size > *VarSize)
+ continue;
// Avoid creating a fragment expression that covers the entire variable.
- if (!VarSize || *VarSize != Size) {
+ if (*VarSize != Size) {
if (auto E =
DIExpression::createFragmentExpression(Expr, Start, Size))
FragmentExpr = *E;
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -5348,8 +5348,7 @@
// If there's no size, the type is broken, but that should be checked
// elsewhere.
auto VarSize = V.getSizeInBits();
- if (!VarSize)
- return;
+ AssertDI(VarSize, "variable with fragments must have a size", Desc, &V);
unsigned FragSize = Fragment.SizeInBits;
unsigned FragOffset = Fragment.OffsetInBits;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87641.291710.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200914/2b17132f/attachment.bin>
More information about the llvm-commits
mailing list