[llvm] r258806 - [DebugInfo] Fix DWARFDebugFrame instruction operand ordering

Igor Laevsky via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 26 05:31:12 PST 2016


Author: igor.laevsky
Date: Tue Jan 26 07:31:11 2016
New Revision: 258806

URL: http://llvm.org/viewvc/llvm-project?rev=258806&view=rev
Log:
[DebugInfo] Fix DWARFDebugFrame instruction operand ordering

We can't rely on the evalution order of function arguments.

Differential Revision: http://reviews.llvm.org/D16509


Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp?rev=258806&r1=258805&r2=258806&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp Tue Jan 26 07:31:11 2016
@@ -160,18 +160,26 @@ void FrameEntry::parseInstructions(DataE
         case DW_CFA_offset_extended:
         case DW_CFA_register:
         case DW_CFA_def_cfa:
-        case DW_CFA_val_offset:
+        case DW_CFA_val_offset: {
           // Operands: ULEB128, ULEB128
-          addInstruction(Opcode, Data.getULEB128(Offset),
-                                 Data.getULEB128(Offset));
+          // Note: We can not embed getULEB128 directly into function
+          // argument list. getULEB128 changes Offset and order of evaluation
+          // for arguments is unspecified.
+          auto op1 = Data.getULEB128(Offset);
+          auto op2 = Data.getULEB128(Offset);
+          addInstruction(Opcode, op1, op2);
           break;
+        }
         case DW_CFA_offset_extended_sf:
         case DW_CFA_def_cfa_sf:
-        case DW_CFA_val_offset_sf:
+        case DW_CFA_val_offset_sf: {
           // Operands: ULEB128, SLEB128
-          addInstruction(Opcode, Data.getULEB128(Offset),
-                                 Data.getSLEB128(Offset));
+          // Note: see comment for the previous case
+          auto op1 = Data.getULEB128(Offset);
+          auto op2 = (uint64_t)Data.getSLEB128(Offset);
+          addInstruction(Opcode, op1, op2);
           break;
+        }
         case DW_CFA_def_cfa_expression:
         case DW_CFA_expression:
         case DW_CFA_val_expression:




More information about the llvm-commits mailing list