Index: clang/lib/Headers/x86gprintrin.h =================================================================== --- clang/lib/Headers/x86gprintrin.h +++ clang/lib/Headers/x86gprintrin.h @@ -20,4 +20,12 @@ #include #endif +void __SSC_MARK(const int Tag) { + int OldEbx; + __asm__ __volatile__("movl %%ebx, %1; movl %0, %%ebx; .byte 0x64, 0x67, 0x90;\ + movl %1, %%ebx" ::"r"(Tag), + "r"(OldEbx) + : "%ebx"); +} + #endif /* __X86GPRINTRIN_H */ Index: clang/test/CodeGen/X86/x86-ssc-mark.c =================================================================== --- /dev/null +++ clang/test/CodeGen/X86/x86-ssc-mark.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 %s -triple=x86_64-unknow-unknow -S -ffreestanding -o - | FileCheck %s + +#include + +// The ebx may be use for base pointer, we need to restore it in time. +void ssc_mark() { +// CHECK-LABEL: __SSC_MARK +// CHECK: movl %edi, -4(%rsp) +// CHECK: movl -4(%rsp), %eax +// CHECK: movl -8(%rsp), %ecx +// CHECK: #APP +// CHECK: movl %ebx, %ecx +// CHECK: movl %eax, %ebx +// CHECK: .byte 100 +// CHECK: .byte 103 +// CHECK: .byte 144 +// CHECK: movl %ecx, %ebx +// CHECK: #NO_APP + + __SSC_MARK(0x0); +}