[PATCH] D125272: [clang] Add -fcheck-new support
Jessica Clarke via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 9 17:48:46 PDT 2022
jrtc27 added inline comments.
================
Comment at: clang/test/CodeGenCXX/fcheck-new.cpp:2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang -fcheck-new -emit-llvm -S %s -o - -O2 | FileCheck %s
+
----------------
heatd wrote:
> jrtc27 wrote:
> > Do you really want -O2 or do you just want to run mem2reg to eliminate all the alloca noise?
> I added -O2 because I was testing with it, since if -fcheck-new doesn't work, it's way more noticeable, as the nullptr check gets optimized out; if it works, the branching is pretty visible and shows exactly what the option does. Also, to eliminate all the noise :) I can definitely remove -O2 though, if you want to.
Thinking about this more, I think the branching complicates matters. All that optimisation happens in LLVM IR land, but you're just touching Clang CodeGen. Is `int *foo() { return new int; }` checking the attributes on the call to _Znwm not enough (and with mem2reg just to clean it up so the function body is trivial)?
Also you should specify a target triple as this will just be LLVM_DEFAULT_TARGET_TRIPLE and change both the type for new (i32 vs i64) and its mangling (j vs m for unsigned int vs unsigned long, and *-windows-msvc is totally different), right?
================
Comment at: clang/test/CodeGenCXX/fcheck-new.cpp:9
+// CHECK: 3:
+// CHECK-NEXT: store i32 48879, ptr [[TMP1]], align 4, !tbaa [[TBAA5:![0-9]+]]
+// CHECK-NEXT: br label [[TMP4]]
----------------
Another advantage of not using -O2 is you lose the TBAA noise
================
Comment at: clang/test/Driver/clang_f_opts.c:73
-
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
----------------
Hmmm
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125272/new/
https://reviews.llvm.org/D125272
More information about the cfe-commits
mailing list