diff options
author | Erich Keane <erich.keane@intel.com> | 2018-12-12 20:30:53 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-12-12 20:30:53 +0000 |
commit | 8c94f07f54519b6c1844fc911d78b9cc7d7abd79 (patch) | |
tree | 97d2d6dd92c50a87b7cebf96863125b0c4809f26 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | c22e62d9a7fbaca8ad17071159e70aae7147ee08 (diff) | |
download | bcm5719-llvm-8c94f07f54519b6c1844fc911d78b9cc7d7abd79.tar.gz bcm5719-llvm-8c94f07f54519b6c1844fc911d78b9cc7d7abd79.zip |
Teach __builtin_unpredictable to work through implicit casts.
The __builtin_unpredictable implementation is confused by any implicit
casts, which happen in C++. This patch strips those off so that
if/switch statements now work with it in C++.
Change-Id: I73c3bf4f1775cd906703880944f4fcdc29fffb0a
llvm-svn: 348969
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 905e7501e01..3f898b19e67 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1701,7 +1701,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, // create metadata that specifies that the branch is unpredictable. // Don't bother if not optimizing because that metadata would not be used. llvm::MDNode *Unpredictable = nullptr; - auto *Call = dyn_cast<CallExpr>(Cond); + auto *Call = dyn_cast<CallExpr>(Cond->IgnoreImpCasts()); if (Call && CGM.getCodeGenOpts().OptimizationLevel != 0) { auto *FD = dyn_cast_or_null<FunctionDecl>(Call->getCalleeDecl()); if (FD && FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) { |