[llvm] r204806 - Change @llvm.clear_cache default to call rt-lib

Renato Golin renato.golin at linaro.org
Wed Mar 26 07:01:32 PDT 2014

Author: rengolin
Date: Wed Mar 26 09:01:32 2014
New Revision: 204806

URL: http://llvm.org/viewvc/llvm-project?rev=204806&view=rev
Change @llvm.clear_cache default to call rt-lib

After some discussion on IRC, emitting a call to the library function seems
like a better default, since it will move from a compiler internal error to
a linker error, that the user can work around until LLVM is fixed.

I'm also adding a note on the responsibility of the user to confirm that
the cache was cleared on platforms where nothing is done.


Modified: llvm/trunk/docs/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=204806&r1=204805&r2=204806&view=diff
--- llvm/trunk/docs/LangRef.rst (original)
+++ llvm/trunk/docs/LangRef.rst Wed Mar 26 09:01:32 2014
@@ -6964,10 +6964,20 @@ Semantics:
 When directly supported, this intrinsic will either return a call to
 the appropriate cache clearing system call (usually ``__clear_cache``)
 when the caches are not unified (ARM, Mips) or just remove the call
-altogether when they are (ex. x86_64).
+altogether when they are (ex. x86_64). Some targets can lower these
+directly into special instructions, if they have it.
-Targets must implement it directly to have either behaviour, as the
-default is to bail with "Not Implemented" message.
+The default behaviour is to emit a call to ``__clear_cache``, so in
+case a target doesn't support it, the user gets a linker error rather
+than a compiler internal error. It also provides a work around to
+the user (implement an empty function called ``__clear_cache``) while
+LLVM doesn't implement it in the target's back-end.
+Please note that the caller is responsible for ensuring the cache
+is actually cleared. This is most important in targets that don't
+need to flush the cache directly (ex. x86_64) and could potentially
+still execute old instructions while the cache is not cleared. LLVM
+will *not* insert nops or busy-wait sequences.
 Standard C Library Intrinsics

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=204806&r1=204805&r2=204806&view=diff
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Mar 26 09:01:32 2014
@@ -2109,8 +2109,9 @@ public:
   /// Return the builtin name for the __builtin___clear_cache intrinsic
+  /// Default is to invoke the clear cache library call
   virtual const char * getClearCacheBuiltinName() const {
-    llvm_unreachable("Not Implemented");
+    return "__clear_cache";
   /// Return the type that should be used to zero or sign extend a

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=204806&r1=204805&r2=204806&view=diff
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Wed Mar 26 09:01:32 2014
@@ -384,11 +384,6 @@ namespace llvm {
     bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
                                            Type *Ty) const override;
-    /// Clear cache library call
-    const char * getClearCacheBuiltinName() const {
-      return "__clear_cache";
-    }
     std::pair<const TargetRegisterClass*, uint8_t>
     findRepresentativeClass(MVT VT) const override;

Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.h?rev=204806&r1=204805&r2=204806&view=diff
--- llvm/trunk/lib/Target/Mips/MipsISelLowering.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsISelLowering.h Wed Mar 26 09:01:32 2014
@@ -585,11 +585,6 @@ namespace llvm {
                                     bool MemcpyStrSrc,
                                     MachineFunction &MF) const;
-    /// Clear cache library call
-    const char * getClearCacheBuiltinName() const {
-      return "__clear_cache";
-    }
     /// isFPImmLegal - Returns true if the target can instruction select the
     /// specified FP immediate natively. If false, the legalizer will
     /// materialize the FP immediate as a load from a constant pool.

More information about the llvm-commits mailing list