diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-01 22:15:34 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-01 22:15:34 +0000 |
commit | cc305617e952f8c3a06b63d9225d0dd7769341b7 (patch) | |
tree | 823aff9761717def368c34947b15390421c9d418 /lib/CodeGen/CGExprScalar.cpp | |
parent | bb12243a487e70c0e65bcebdaa12ad754f92e022 (diff) |
Split emission of -ftrapv checks and -fcatch-undefined-behavior checks into
separate functions, since they share essentially no code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167259 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 2354f31ede..31ec7ea88f 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -2021,6 +2021,12 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { const std::string *handlerName = &CGF.getContext().getLangOpts().OverflowHandler; if (handlerName->empty()) { + // If -fcatch-undefined-behavior is enabled, emit a call to its + // runtime. Otherwise, this is a -ftrapv check, so just emit a trap. + if (CGF.CatchUndefined) + EmitBinOpCheck(Builder.CreateNot(overflow), Ops); + else + CGF.EmitTrapvCheck(Builder.CreateNot(overflow)); EmitBinOpCheck(Builder.CreateNot(overflow), Ops); return result; } |