DebugInfo: Remove 'inlinedAt:' field from MDLocalVariable
Remove 'inlinedAt:' from MDLocalVariable. Besides saving some memory
(variables with it seem to be single largest `Metadata` contributer to
memory usage right now in -g -flto builds), this stops optimization and
backend passes from having to change local variables.
The 'inlinedAt:' field was used by the backend in two ways:
1. To tell the backend whether and into what a variable was inlined.
2. To create a unique id for each inlined variable.
Instead, rely on the 'inlinedAt:' field of the intrinsic's `!dbg`
attachment, and change the DWARF backend to use a typedef called
`InlinedVariable` which is `std::pair<MDLocalVariable*, MDLocation*>`.
This `DebugLoc` is already passed reliably through the backend (as
verified by r234021).
This commit removes the check from r234021, but I added a new check
(that will survive) in r235048, and changed the `DIBuilder` API in
r235041 to require a `!dbg` attachment whose 'scope:` is in the same
`MDSubprogram` as the variable's.
If this breaks your out-of-tree testcases, perhaps the script I used
(mdlocalvariable-drop-inlinedat.sh) will help; I'll attach it to PR22778
in a moment.
llvm-svn: 235050
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 01bcb30..46e376a 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -1813,11 +1813,9 @@
MDTypeRef Type = getDerivedType();
unsigned Arg = 6;
unsigned Flags = 7;
- MDLocation *InlinedAt =
- MDLocation::getDistinct(Context, 10, 20, getSubprogram());
auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, InlinedAt);
+ Arg, Flags);
EXPECT_EQ(Tag, N->getTag());
EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName());
@@ -1826,46 +1824,28 @@
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(Arg, N->getArg());
EXPECT_EQ(Flags, N->getFlags());
- EXPECT_EQ(InlinedAt, N->getInlinedAt());
EXPECT_EQ(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, InlinedAt));
+ Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, dwarf::DW_TAG_auto_variable, Scope,
- Name, File, Line, Type, Arg, Flags,
- InlinedAt));
+ Name, File, Line, Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, getSubprogram(), Name, File,
- Line, Type, Arg, Flags, InlinedAt));
+ Line, Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, "other", File, Line,
- Type, Arg, Flags, InlinedAt));
+ Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, getFile(), Line,
- Type, Arg, Flags, InlinedAt));
+ Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1,
- Type, Arg, Flags, InlinedAt));
+ Type, Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line,
- getDerivedType(), Arg, Flags, InlinedAt));
+ getDerivedType(), Arg, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg + 1, Flags, InlinedAt));
+ Arg + 1, Flags));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, ~Flags, InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(
- Context, Tag, Scope, Name, File, Line, Type, Arg, Flags,
- MDLocation::getDistinct(Context, 10, 20, getSubprogram())));
+ Arg, ~Flags));
TempMDLocalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
-
- auto *Inlined = N->withoutInline();
- EXPECT_NE(N, Inlined);
- EXPECT_EQ(N->getTag(), Inlined->getTag());
- EXPECT_EQ(N->getScope(), Inlined->getScope());
- EXPECT_EQ(N->getName(), Inlined->getName());
- EXPECT_EQ(N->getFile(), Inlined->getFile());
- EXPECT_EQ(N->getLine(), Inlined->getLine());
- EXPECT_EQ(N->getType(), Inlined->getType());
- EXPECT_EQ(N->getArg(), Inlined->getArg());
- EXPECT_EQ(N->getFlags(), Inlined->getFlags());
- EXPECT_EQ(nullptr, Inlined->getInlinedAt());
- EXPECT_EQ(N, Inlined->withInline(cast<MDLocation>(InlinedAt)));
}
typedef MetadataTest MDExpressionTest;