[PATCH] Add function to get the number of DFSan labels allocated.

Peter Collingbourne peter at pcc.me.uk
Tue Mar 18 17:58:33 PDT 2014



================
Comment at: test/dfsan/label_count.c:35
@@ +34,3 @@
+  // Create a value that combines i and j.
+  int i_plus_j = i + j;
+
----------------
This makes the test sensitive to the optimization level, as the compiler could in principle discard this assignment. Although this might not be causing any problems now I'd rather avoid the possibility of mysterious test failures later.

I wonder whether a better way to structure this test would be to split it into two translation units in order to inhibit optimizations. (The add and multiply operations could be moved to functions in the other translation unit while everything else could stay where it currently is.)

================
Comment at: lib/dfsan/dfsan.cc:233
@@ -232,1 +232,3 @@
 
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE int
+dfsan_get_label_count(void) {
----------------
Is "int" the right return type for this function? I'd imagine it should be "dfsan_label", especially if we ever extend dfsan_label to 32 bits in the future.

================
Comment at: include/sanitizer/dfsan_interface.h:77
@@ -76,1 +76,3 @@
 
+/// Return the number of labels allocated.
+unsigned dfsan_get_label_count();
----------------
nit: Returns (third person, like the other functions).

================
Comment at: include/sanitizer/dfsan_interface.h:78
@@ +77,3 @@
+/// Return the number of labels allocated.
+unsigned dfsan_get_label_count();
+
----------------
Should be (void) for C compatibility.

Also, the type does not match the definition (see also my comment there). Note that declarations here have to be duplicated into lib/dfsan/dfsan.h because of toolchain limitations (see D2179).


http://llvm-reviews.chandlerc.com/D3109



More information about the llvm-commits mailing list