r341699 - [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 7 12:14:24 PDT 2018
Author: ctopper
Date: Fri Sep 7 12:14:24 2018
New Revision: 341699
URL: http://llvm.org/viewvc/llvm-project?rev=341699&view=rev
Log:
[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
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/rd-builtins.c
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=341699&r1=341698&r2=341699&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 7 12:14:24 2018
@@ -9158,6 +9158,12 @@ Value *CodeGenFunction::EmitX86BuiltinEx
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:
Modified: cfe/trunk/test/CodeGen/rd-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rd-builtins.c?rev=341699&r1=341698&r2=341699&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/rd-builtins.c (original)
+++ cfe/trunk/test/CodeGen/rd-builtins.c Fri Sep 7 12:14:24 2018
@@ -14,3 +14,12 @@ int test_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);
+}
More information about the cfe-commits
mailing list