forked from OSchip/llvm-project
[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
This commit is contained in:
parent
4863313b35
commit
ecf2e2fe31
|
@ -9158,6 +9158,12 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
||||||
case X86::BI__rdtsc: {
|
case X86::BI__rdtsc: {
|
||||||
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_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_undef128:
|
||||||
case X86::BI__builtin_ia32_undef256:
|
case X86::BI__builtin_ia32_undef256:
|
||||||
case X86::BI__builtin_ia32_undef512:
|
case X86::BI__builtin_ia32_undef512:
|
||||||
|
|
|
@ -14,3 +14,12 @@ int test_rdtsc() {
|
||||||
// CHECK: @test_rdtsc
|
// CHECK: @test_rdtsc
|
||||||
// CHECK: call i64 @llvm.x86.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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue