llvm-project/clang/test/CodeGen/rd-builtins.c
Craig Topper ecf2e2fe31 [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
This is the clang side of D51803. The llvm intrinsic now returns two results. So we need to emit an explicit store in IR for the out parameter. This is similar to addcarry/subborrow/rdrand/rdseed.

Differential Revision: https://reviews.llvm.org/D51805

llvm-svn: 341699
2018-09-07 19:14:24 +00:00

26 lines
679 B
C

// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
#include <x86intrin.h>
unsigned long long test_rdpmc(int a) {
return _rdpmc(a);
// CHECK: @test_rdpmc
// CHECK: call i64 @llvm.x86.rdpmc
}
int test_rdtsc() {
return _rdtsc();
// CHECK: @test_rdtsc
// CHECK: call i64 @llvm.x86.rdtsc
}
unsigned long long test_rdtscp(unsigned int *a) {
// CHECK: @test_rdtscp
// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp
// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1
// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}}
// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0
return __rdtscp(a);
}