[clang] Sanitizer: Support -fwrapv with -fsanitize=signed-integer-overflow (PR #82432)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 14:37:19 PST 2024


================
@@ -723,7 +723,9 @@ class ScalarExprEmitter
     if (Ops.Ty->isSignedIntegerOrEnumerationType()) {
       switch (CGF.getLangOpts().getSignedOverflowBehavior()) {
       case LangOptions::SOB_Defined:
-        return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
+        if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
----------------
JustinStitt wrote:

One creates `CreateMul` and other `CreateNSWMul`. I believe this is useful for optimizations later

https://github.com/llvm/llvm-project/pull/82432


More information about the cfe-commits mailing list