[cfe-commits] r130172 - /cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Apr 25 16:10:07 PDT 2011
Author: fjahanian
Date: Mon Apr 25 18:10:07 2011
New Revision: 130172
URL: http://llvm.org/viewvc/llvm-project?rev=130172&view=rev
Log:
Generalize case for built-in expressions having
side-effect to generate their ir. Not just for
__builtin_expect. // rdar://9330105
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=130172&r1=130171&r2=130172&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Apr 25 18:10:07 2011
@@ -176,16 +176,8 @@
unsigned BuiltinID, const CallExpr *E) {
// See if we can constant fold this builtin. If so, don't emit it at all.
Expr::EvalResult Result;
- if (E->Evaluate(Result, CGM.getContext())) {
- // Short circuiting the __builtin_expect on its 1st argument
- // must still IR-gen the 1st and 2nd argument's side-effect.
- if (BuiltinID == Builtin::BI__builtin_expect) {
- if (E->getArg(0)->HasSideEffects(getContext()))
- (void)EmitScalarExpr(E->getArg(0));
- if (E->getArg(1)->HasSideEffects(getContext()))
- (void)EmitScalarExpr(E->getArg(1));
- }
-
+ if (E->Evaluate(Result, CGM.getContext()) &&
+ !Result.hasSideEffects()) {
if (Result.Val.isInt())
return RValue::get(llvm::ConstantInt::get(getLLVMContext(),
Result.Val.getInt()));
@@ -321,9 +313,10 @@
}
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(EmitScalarExpr(E->getArg(0)));
+ return RValue::get(ArgValue);
}
case Builtin::BI__builtin_bswap32:
case Builtin::BI__builtin_bswap64: {
More information about the cfe-commits
mailing list