Attach AT_APPLE_optimized attribute to optimized function's debug info.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.cpp
index 1a97ae77ebb6e3c1fdd104a64bb75d28cfa9dde8..e68a17d7af9b919c42c5be5b5e23a66ff39bef5c 100644 (file)
@@ -1328,12 +1328,18 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
   if (SP.isArtificial())
     addUInt(SPDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
 
-  // DW_TAG_inlined_subroutine may refer to this DIE.
-  ModuleCU->insertDIE(SP.getNode(), SPDie);
+  if (!SP.isLocalToUnit())
+    addUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
   
+  if (SP.isOptimized())
+    addUInt(SPDie, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1);
+
   if (!DisableFramePointerElim(*Asm->MF))
     addUInt(SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr, dwarf::DW_FORM_flag, 1);
 
+  // DW_TAG_inlined_subroutine may refer to this DIE.
+  ModuleCU->insertDIE(SP.getNode(), SPDie);
+
   return SPDie;
 }
 
@@ -1424,9 +1430,6 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
   MachineLocation Location(RI->getFrameRegister(*Asm->MF));
   addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
 
-  if (!DISubprogram(SPNode).isLocalToUnit())
-    addUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
-  
   return SPDie;
 }