DebugInfo: Restrict DW_AT_high_pc encoding as data4 offset to DWARF 4 as per spec
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.cpp
index 7abd2f1dc73018e69047220a80e03c7fdc63e9cb..882720fcae6badceb53d7b2c0330cdf7154ce5af 100644 (file)
@@ -413,8 +413,11 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
   }
 
   SPCU->addLabelAddress(SPDie, dwarf::DW_AT_low_pc, FunctionBeginSym);
-  SPCU->addLabelDelta(SPDie, dwarf::DW_AT_high_pc, FunctionEndSym,
-                      FunctionBeginSym);
+  if (DwarfVersion < 4 || Triple(Asm->getTargetTriple()).isOSDarwin())
+    SPCU->addLabelAddress(SPDie, dwarf::DW_AT_high_pc, FunctionEndSym);
+  else
+    SPCU->addLabelDelta(SPDie, dwarf::DW_AT_high_pc, FunctionEndSym,
+                        FunctionBeginSym);
 
   const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
   MachineLocation Location(RI->getFrameRegister(*Asm->MF));
@@ -1607,7 +1610,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
         History.push_back(MI);
       } else {
         // Not a DBG_VALUE instruction.
-        if (!MI->isLabel())
+        if (!MI->isPosition())
           AtBlockEntry = false;
 
         // First known non-DBG_VALUE and non-frame setup location marks