Only add DW_AT_prototyped if we're working with a C-like language.
authorEric Christopher <echristo@apple.com>
Wed, 22 Feb 2012 08:46:21 +0000 (08:46 +0000)
committerEric Christopher <echristo@apple.com>
Wed, 22 Feb 2012 08:46:21 +0000 (08:46 +0000)
Worth another 45k (1%) off of a large C++ testcase.

rdar://10909458

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151144 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
test/DebugInfo/X86/DW_AT_specification.ll
test/DebugInfo/X86/concrete_out_of_line.ll
test/DebugInfo/X86/pr11300.ll

index d215e922ec20fafc4f04a711949283202ce21d5d..51c635e268cc75190e8d088f88cad39f57883b22 100644 (file)
@@ -780,8 +780,12 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
         Buffer.addChild(Arg);
       }
     }
-    // Add prototype flag.
-    if (isPrototyped)
+    // Add prototype flag if we're dealing with a C language and the
+    // function has been prototyped.
+    if (isPrototyped &&
+       (Language == dwarf::DW_LANG_C89 ||
+        Language == dwarf::DW_LANG_C99 ||
+        Language == dwarf::DW_LANG_ObjC))
       addUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
   }
     break;
@@ -1023,7 +1027,12 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
 
   addSourceLine(SPDie, SP);
 
-  if (SP.isPrototyped()) 
+  // Add the prototype if we have a prototype and we have a C like
+  // language.
+  if (SP.isPrototyped() &&
+      (Language == dwarf::DW_LANG_C89 ||
+       Language == dwarf::DW_LANG_C99 ||
+       Language == dwarf::DW_LANG_ObjC))
     addUInt(SPDie, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
 
   // Add Return Type.
index fc6cd4bbe4c73603c4df69d3bd8edab32b5e4951..e4c5c807bfdbc22a597cec53585d60abb6905b00 100644 (file)
@@ -4,7 +4,7 @@
 ; test that the DW_AT_specification is a back edge in the file.
 
 ; CHECK: 0x00000038: DW_TAG_subprogram [5] *
-; CHECK: 0x0000005f: DW_AT_specification [DW_FORM_ref4]      (cu + 0x0038 => {0x00000038})
+; CHECK: 0x0000005e: DW_AT_specification [DW_FORM_ref4]      (cu + 0x0038 => {0x00000038})
 
 
 @_ZZN3foo3barEvE1x = constant i32 0, align 4
index 18948445157f7ec1f354b4b25ac44c6a78451295..055a9bf034f60918da57fbacc3d020f32e9c8c11 100644 (file)
@@ -7,7 +7,7 @@
 ; first check that we have a TAG_subprogram at a given offset and it has
 ; AT_inline.
 
-; CHECK: 0x00000134:   DW_TAG_subprogram
+; CHECK: 0x00000130:   DW_TAG_subprogram [18]
 ; CHECK-NEXT:     DW_AT_MIPS_linkage_name
 ; CHECK-NEXT:     DW_AT_specification
 ; CHECK-NEXT:     DW_AT_inline
@@ -15,8 +15,8 @@
 
 ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
 
-; CHECK: 0x00000184:   DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x0134 => {0x00000134})
+; CHECK: 0x00000180:   DW_TAG_subprogram [20]
+; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x0130 => {0x00000130})
 
 define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
 entry:
index 507e3f6d9b49d49627fd32ede0fde3061f3ff881..84884348e2aa73a04418e6dee0ad8e2fcfd08fb5 100644 (file)
@@ -3,8 +3,8 @@
 
 ; test that the DW_AT_specification is a back edge in the file.
 
-; CHECK: 0x0000005b:     DW_TAG_subprogram [5]
-; CHECK: 0x0000007c:     DW_AT_specification [DW_FORM_ref4]      (cu + 0x005b => {0x0000005b})
+; CHECK: 0x0000005a:     DW_TAG_subprogram [5]
+; CHECK: 0x0000007a:     DW_AT_specification [DW_FORM_ref4]      (cu + 0x005a => {0x0000005a})
 
 %struct.foo = type { i8 }