aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorJakub Staszak <jstaszak@apple.com>2011-07-08 22:45:14 +0000
committerJakub Staszak <jstaszak@apple.com>2011-07-08 22:45:14 +0000
commit558229f267d2cdee69639df04382082e7c7ad54c (patch)
tree4872fe6f3834b9529eee90252600da895f611c90 /lib/CodeGen
parentdf41b4c10ab2a0096957e415e520bd467f8b2e9e (diff)
Introduce __builtin_expect() intrinsic support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134761 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 269917b442..8f29663613 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -22,6 +22,7 @@
#include "clang/Basic/TargetBuiltins.h"
#include "llvm/Intrinsics.h"
#include "llvm/Target/TargetData.h"
+
using namespace clang;
using namespace CodeGen;
using namespace llvm;
@@ -311,11 +312,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
return RValue::get(Result);
}
case Builtin::BI__builtin_expect: {
- // FIXME: pass expect through to LLVM
Value *ArgValue = EmitScalarExpr(E->getArg(0));
- if (E->getArg(1)->HasSideEffects(getContext()))
- (void)EmitScalarExpr(E->getArg(1));
- return RValue::get(ArgValue);
+ const llvm::Type *ArgType = ArgValue->getType();
+
+ Value *FnExpect = CGM.getIntrinsic(Intrinsic::expect, &ArgType, 1);
+ Value *ExpectedValue = EmitScalarExpr(E->getArg(1));
+
+ Value *Result = Builder.CreateCall2(FnExpect, ArgValue, ExpectedValue,
+ "expval");
+ return RValue::get(Result);
+
}
case Builtin::BI__builtin_bswap32:
case Builtin::BI__builtin_bswap64: {