clayborg added a comment.

Will the floating point emulation be perfect compared to actually JITing the 
code? If we are going to enable this feature I would like to see tests that 
actually JIT code do the same operations somehow to verify that things match up 
with the IR interpreted results produce. The main reason we didn't include 
floating point code in the IR interpreter before is it is harder to make things 
match up with exactly how things are going to be run if it were JIT'ed into the 
process. On x86_64 or x64 there are floating point settings that can be changed 
and affect how operations happen in the current thread. The main example I 
always think of is how older debuggers would create recursive descent parsers 
and evaluate floating point operations using native floating point types. I 
believe that our APFloat classes can do everything correctly, but I would like 
to see tests that verify that we get the same results as if we were running 
actual code in the process. For this you can add an extra function to the 
lldb/test/API/lang/c/fpeval/main.c source like:

  typedef enum FloatOperation { add, subtract, multiply, ... };
  double eval(double a, double b, FloatOperation op) {
    switch (op) {
    case add: return a+b;
    case subtract: return a-b;
    ...
    }
  }



================
Comment at: lldb/test/API/lang/c/fpeval/TestFPEval.py:32
+        self.runCmd("run", RUN_SUCCEEDED)
+        self.expect("expr --allow-jit false  -- a + b", 
VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=['double', '44'])
----------------
You might be able to get away with not actually even creating a target or 
running to main if you define variables in your expression:

```
self.expect('expr --allow-jit false  -- float x=2.2; float y=4.4; x+y', ...
```


================
Comment at: lldb/test/API/lang/c/fpeval/main.c:3-4
+{
+    double a = 42.0;
+    double b = 2.0;
+    return 0; //// Set break point at this line.
----------------
We should be testing "float" and "long double" as well to verify those work.


================
Comment at: lldb/test/API/lang/c/fpeval/main.c:1-10
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+int main (int argc, char const *argv[])
+{
+    double a = 42.0;
----------------
I don't think this file is even needed if you define variables locally in your 
own expression each time like I mentioned above ("expr float x=2.2; float 
y=4.4; x+y")


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126359/new/

https://reviews.llvm.org/D126359

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to