Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9158,6 +9158,12 @@ case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { + Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); + Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); + return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: Index: test/CodeGen/rd-builtins.c =================================================================== --- test/CodeGen/rd-builtins.c +++ test/CodeGen/rd-builtins.c @@ -14,3 +14,12 @@ // 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); +}