Skip to content

Commit a96fe8d

Browse files
committed
Add support for __builtin_expect which is needed for assert,
among other things. Also change a codegen warning to dump to stderr so it doesn't mess with -emit-llvm output llvm-svn: 44497
1 parent 9724ce1 commit a96fe8d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

clang/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
9797

9898
return RValue::get(Result);
9999
}
100+
case Builtin::BI__builtin_expect: {
101+
llvm::Value *Condition = EmitScalarExpr(E->getArg(0));
102+
return RValue::get(Condition);
103+
}
100104
}
101105

102106
return RValue::get(0);

clang/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
3838
else
3939
EmitAggExpr(E, 0, false);
4040
} else {
41-
printf("Unimplemented stmt!\n");
41+
fprintf(stderr, "Unimplemented stmt!\n");
4242
S->dump(getContext().SourceMgr);
4343
}
4444
break;

clang/include/clang/AST/Builtins.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ BUILTIN(__builtin_va_start, "va&.", "n")
6767
BUILTIN(__builtin_va_end, "va&", "n")
6868
BUILTIN(__builtin_va_copy, "va&a", "n")
6969
BUILTIN(__builtin_memcpy, "v*v*vC*z", "n")
70+
BUILTIN(__builtin_expect, "iii" , "nc")
7071

7172
#undef BUILTIN

0 commit comments

Comments
 (0)