[llvm] r226291 - IR: Allow 16-bits for column info

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Jan 16 09:33:08 PST 2015


Author: dexonsmith
Date: Fri Jan 16 11:33:08 2015
New Revision: 226291

URL: http://llvm.org/viewvc/llvm-project?rev=226291&view=rev
Log:
IR: Allow 16-bits for column info

Raise the limit for column information from 8 bits to 16 bits.

Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/IR/Metadata.cpp
    llvm/trunk/test/Assembler/invalid-mdlocation-overflow-column.ll
    llvm/trunk/test/Assembler/mdlocation.ll
    llvm/trunk/unittests/IR/MetadataTest.cpp

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=226291&r1=226290&r2=226291&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Jan 16 11:33:08 2015
@@ -3002,7 +3002,7 @@ bool LLParser::ParseSpecializedMDNode(MD
 ///   ::= !MDLocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
 bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
   MDUnsignedField<uint32_t> line(0, ~0u >> 8);
-  MDUnsignedField<uint32_t> column(0, ~0u >> 24);
+  MDUnsignedField<uint32_t> column(0, ~0u >> 16);
   MDField scope;
   MDField inlinedAt;
   if (ParseMDFieldsImpl([&]() -> bool {

Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=226291&r1=226290&r2=226291&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Fri Jan 16 11:33:08 2015
@@ -653,7 +653,7 @@ MDLocation::MDLocation(LLVMContext &C, u
 
   // Set line and column.
   assert(Line < (1u << 24) && "Expected 24-bit line");
-  assert(Column < (1u << 8) && "Expected 8-bit column");
+  assert(Column < (1u << 16) && "Expected 16-bit column");
 
   MDNodeSubclassData = Line;
   SubclassData16 = Column;
@@ -676,8 +676,8 @@ static void adjustLine(unsigned &Line) {
 }
 
 static void adjustColumn(unsigned &Column) {
-  // Set to unknown on overflow.  Still use 8 bits for now.
-  if (Column >= (1u << 8))
+  // Set to unknown on overflow.  We only have 16 bits to play with here.
+  if (Column >= (1u << 16))
     Column = 0;
 }
 

Modified: llvm/trunk/test/Assembler/invalid-mdlocation-overflow-column.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdlocation-overflow-column.ll?rev=226291&r1=226290&r2=226291&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdlocation-overflow-column.ll (original)
+++ llvm/trunk/test/Assembler/invalid-mdlocation-overflow-column.ll Fri Jan 16 11:33:08 2015
@@ -3,7 +3,7 @@
 !0 = !{}
 
 ; CHECK-NOT: error
-!1 = !MDLocation(column: 255, scope: !0)
+!1 = !MDLocation(column: 65535, scope: !0)
 
-; CHECK: <stdin>:[[@LINE+1]]:26: error: value for 'column' too large, limit is 255
-!2 = !MDLocation(column: 256, scope: !0)
+; CHECK: <stdin>:[[@LINE+1]]:26: error: value for 'column' too large, limit is 65535
+!2 = !MDLocation(column: 65536, scope: !0)

Modified: llvm/trunk/test/Assembler/mdlocation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/mdlocation.ll?rev=226291&r1=226290&r2=226291&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/mdlocation.ll (original)
+++ llvm/trunk/test/Assembler/mdlocation.ll Fri Jan 16 11:33:08 2015
@@ -1,8 +1,8 @@
 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
 ; RUN: verify-uselistorder %s
 
-; CHECK: !named = !{!0, !1, !1, !2, !2, !3, !3}
-!named = !{!0, !1, !2, !3, !4, !5, !6}
+; CHECK: !named = !{!0, !1, !1, !2, !2, !3, !3, !4}
+!named = !{!0, !1, !2, !3, !4, !5, !6, !7}
 
 ; CHECK: !0 = !{}
 !0 = !{}
@@ -18,3 +18,6 @@
 ; CHECK-NEXT: !3 = !MDLocation(line: 0, scope: !0)
 !5 = !MDLocation(scope: !0)
 !6 = !MDLocation(scope: !0, column: 0, line: 0)
+
+; CHECK-NEXT: !4 = !MDLocation(line: 16777215, column: 65535, scope: !0)
+!7 = !MDLocation(line: 16777215, column: 65535, scope: !0)

Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=226291&r1=226290&r2=226291&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Fri Jan 16 11:33:08 2015
@@ -397,19 +397,19 @@ TEST_F(MDLocationTest, Overflow) {
     EXPECT_EQ(7u, L->getColumn());
   }
   unsigned U24 = 1u << 24;
-  unsigned U8 = 1u << 8;
+  unsigned U16 = 1u << 16;
   {
-    MDLocation *L = MDLocation::get(Context, U24 - 1, U8 - 1, N);
+    MDLocation *L = MDLocation::get(Context, U24 - 1, U16 - 1, N);
     EXPECT_EQ(U24 - 1, L->getLine());
-    EXPECT_EQ(U8 - 1, L->getColumn());
+    EXPECT_EQ(U16 - 1, L->getColumn());
   }
   {
-    MDLocation *L = MDLocation::get(Context, U24, U8, N);
+    MDLocation *L = MDLocation::get(Context, U24, U16, N);
     EXPECT_EQ(0u, L->getLine());
     EXPECT_EQ(0u, L->getColumn());
   }
   {
-    MDLocation *L = MDLocation::get(Context, U24 + 1, U8 + 1, N);
+    MDLocation *L = MDLocation::get(Context, U24 + 1, U16 + 1, N);
     EXPECT_EQ(0u, L->getLine());
     EXPECT_EQ(0u, L->getColumn());
   }





More information about the llvm-commits mailing list