mstorsjo created this revision.
mstorsjo added reviewers: joerg, compnerd, mclow.lists, EricWF, ldionne.
Herald added subscribers: libcxx-commits, kristof.beyls, krytarowski, 
javed.absar, aprantl.

The existing typedef of unw_fpreg_t to uint64_t might work and be correct for 
the ARM_EHABI case, but for dwarf, some cases in e.g. DwarfInstructions.hpp 
convert between double and unw_fpreg_t.

When converting implicitly between double and unw_fpreg_t (uint64_t), the 
values get interpreted as integers and converted to float and vice versa, while 
the correct thing would be to keep the same bit pattern.

Avoid the whole issue by using the same definition of unw_fpreg_t as all other 
architectures, when using dwarf unwinding on ARM.

AFAIK NetBSD uses dwarf unwinding on ARM, and I'm doing the same for MinGW/ARM.

I'm not aware of a testcase where the current setup of `unw_fpreg_t `would 
produce incorrect results, but building produces the following warnings:

  src/libunwind.cpp:236:61: warning: format specifies type
        'double' but the argument has type 'unw_fpreg_t'
        (aka 'unsigned long long') [-Wformat]
                         static_cast<void *>(cursor), regNum, value);
                                                              ^~~~~
  
  src/DwarfInstructions.hpp:178:20: warning: implicit conversion
        turns floating-point number into integer: 'double' to 'unw_fpreg_t' 
(aka 
        'unsigned long long') [-Wfloat-conversion]
                  i, getSavedFloatRegister(addressSpace, registers, cfa,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Repository:
  rUNW libunwind

https://reviews.llvm.org/D57001

Files:
  include/libunwind.h


Index: include/libunwind.h
===================================================================
--- include/libunwind.h
+++ include/libunwind.h
@@ -76,7 +76,7 @@
 
 typedef int unw_regnum_t;
 typedef uintptr_t unw_word_t;
-#if defined(__arm__)
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
 typedef uint64_t unw_fpreg_t;
 #else
 typedef double unw_fpreg_t;


Index: include/libunwind.h
===================================================================
--- include/libunwind.h
+++ include/libunwind.h
@@ -76,7 +76,7 @@
 
 typedef int unw_regnum_t;
 typedef uintptr_t unw_word_t;
-#if defined(__arm__)
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
 typedef uint64_t unw_fpreg_t;
 #else
 typedef double unw_fpreg_t;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to