Index: include/llvm/IR/IntrinsicsX86.td =================================================================== --- include/llvm/IR/IntrinsicsX86.td +++ include/llvm/IR/IntrinsicsX86.td @@ -3473,10 +3473,13 @@ } //===----------------------------------------------------------------------===// -// CLFLUSHOPT +// CLFLUSHOPT and CLWB let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_clflushopt : GCCBuiltin<"__builtin_ia32_clflushopt">, Intrinsic<[], [llvm_ptr_ty], []>; + + def int_x86_clwb : GCCBuiltin<"__builtin_ia32_clwb">, + Intrinsic<[], [llvm_ptr_ty], []>; } //===----------------------------------------------------------------------===// Index: lib/Target/X86/X86InstrInfo.td =================================================================== --- lib/Target/X86/X86InstrInfo.td +++ lib/Target/X86/X86InstrInfo.td @@ -2698,9 +2698,9 @@ def CLFLUSHOPT : I<0xAE, MRM7m, (outs), (ins i8mem:$src), "clflushopt\t$src", [(int_x86_clflushopt addr:$src)]>, PD; -// TODO: Add an instrincis for this. let Predicates = [HasCLWB] in -def CLWB : I<0xAE, MRM6m, (outs), (ins i8mem:$src), "clwb\t$src", []>, PD; +def CLWB : I<0xAE, MRM6m, (outs), (ins i8mem:$src), "clwb\t$src", + [(int_x86_clwb addr:$src)]>, PD; //===----------------------------------------------------------------------===// Index: test/CodeGen/X86/clwb.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/clwb.ll @@ -0,0 +1,13 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=clwb | FileCheck %s + +define void @clwb(i8* %p) nounwind { +; CHECK-LABEL: clwb: +; CHECK: ## BB#0: +; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax +; CHECK-NEXT: clwb (%eax) +; CHECK-NEXT: retl + tail call void @llvm.x86.clwb(i8* %p) + ret void +} +declare void @llvm.x86.clwb(i8*) nounwind