[PATCH] [RFC] __builtin___clear_cache support in LLVM

JF Bastien jfb at chromium.org
Fri Mar 14 11:54:23 PDT 2014


  I'm not sure on whether this is the right place to modify the code, or if other modifications should be done.


================
Comment at: include/llvm/IR/Intrinsics.td:515
@@ +514,3 @@
+def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
+                                [IntrReadWriteArgMem], "llvm.clear_cache">;
+
----------------
Maybe I'm being overly paranoid, but __clear_cache is sometimes used when something is mapped at multiple virtual addresses. IIUC having ReadWriteArgMem wouldn't be correct in these cases, even if the amount of memory accessed from the arguments is unspecified. I think specifying nothing would be better (equivalent to the non-existent ReadWriteMem?).

================
Comment at: include/llvm/Target/TargetLowering.h:2114
@@ +2113,3 @@
+    return 0;
+  }
+
----------------
This seems like a pretty bad silent failure waiting to occur for targets other than x86/ARM/MIPS: implementor won't know that they have to add this. Making the function pure virtual would force everyone to return 0 when, like x86, there's nothing to do, and in all other cases they'd need to do the right thing for their platform. It's either break everyone's build loudly, or everyone's runtime silently.

It would also help understanding if the comment said that return 0 means "call nothing" (unless I misunderstood and that's not what it means).

================
Comment at: test/CodeGen/X86/cache-intrinsic.ll:20
@@ +19,3 @@
+
+; CHECK-NOT: __clear_cache
+
----------------
Comment that x86 doesn't need to clear the cache? clear_cache.c says "Intel processors have a unified instruction and data cache so there is nothing to do."


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



More information about the llvm-commits mailing list