[llvm] r235955 - DebugInfo: Support up to 2^16 arguments in a subprogram
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 27 18:07:34 PDT 2015
Author: dexonsmith
Date: Mon Apr 27 20:07:33 2015
New Revision: 235955
URL: http://llvm.org/viewvc/llvm-project?rev=235955&view=rev
Log:
DebugInfo: Support up to 2^16 arguments in a subprogram
Support up to 2^16 arguments to a function. If we do hit the limit,
assert out rather than restarting at 0 as we've done historically.
This fixes PR23332. A clang test will follow.
Modified:
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=235955&r1=235954&r2=235955&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Mon Apr 27 20:07:33 2015
@@ -456,11 +456,8 @@ MDLocalVariable *MDLocalVariable::getImp
Metadata *Type, unsigned Arg,
unsigned Flags, StorageType Storage,
bool ShouldCreate) {
- // Truncate Arg to 8 bits.
- //
- // FIXME: This is gross (and should be changed to an assert or removed), but
- // it matches historical behaviour for now.
- Arg &= (1u << 8) - 1;
+ // 64K ought to be enough for any frontend.
+ assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString");
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=235955&r1=235954&r2=235955&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Mon Apr 27 20:07:33 2015
@@ -1849,6 +1849,26 @@ TEST_F(MDLocalVariableTest, get) {
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+TEST_F(MDLocalVariableTest, getArg256) {
+ EXPECT_EQ(255u, MDLocalVariable::get(Context, dwarf::DW_TAG_arg_variable,
+ getSubprogram(), "", getFile(), 0,
+ nullptr, 255, 0)
+ ->getArg());
+ EXPECT_EQ(256u, MDLocalVariable::get(Context, dwarf::DW_TAG_arg_variable,
+ getSubprogram(), "", getFile(), 0,
+ nullptr, 256, 0)
+ ->getArg());
+ EXPECT_EQ(257u, MDLocalVariable::get(Context, dwarf::DW_TAG_arg_variable,
+ getSubprogram(), "", getFile(), 0,
+ nullptr, 257, 0)
+ ->getArg());
+ unsigned Max = UINT16_MAX;
+ EXPECT_EQ(Max, MDLocalVariable::get(Context, dwarf::DW_TAG_arg_variable,
+ getSubprogram(), "", getFile(), 0,
+ nullptr, Max, 0)
+ ->getArg());
+}
+
typedef MetadataTest MDExpressionTest;
TEST_F(MDExpressionTest, get) {
More information about the llvm-commits
mailing list