Skip to content

Commit 1b1c8d8

Browse files
committed
[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169
1 parent e7c8cd4 commit 1b1c8d8

File tree

1,128 files changed

+41260
-41405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,128 files changed

+41260
-41405
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
6464
CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
6565
CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, experimental
6666
///< strict floating point.
67-
CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes on IR call arguments and return values
67+
CODEGENOPT(DisableNoundefAttrs, 1, 0) ///< Disable emitting `noundef` attributes on IR call arguments and return values
6868
CODEGENOPT(LegacyPassManager, 1, 0) ///< Use the legacy pass manager.
6969
CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
7070
///< pass manager.

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,10 +5396,9 @@ defm clear_ast_before_backend : BoolOption<"",
53965396
PosFlag<SetTrue, [], "Clear">,
53975397
NegFlag<SetFalse, [], "Don't clear">,
53985398
BothFlags<[], " the Clang AST before running backend code generation">>;
5399-
def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group<f_Group>,
5400-
HelpText<"Enable analyzing function argument and return types for mandatory definedness">,
5401-
MarshallingInfoFlag<CodeGenOpts<"EnableNoundefAttrs">>,
5402-
ImpliedByAnyOf<[fsanitize_memory_param_retval.KeyPath]>;
5399+
def disable_noundef_analysis : Flag<["-"], "disable-noundef-analysis">, Group<f_Group>,
5400+
HelpText<"Disable analyzing function argument and return types for mandatory definedness">,
5401+
MarshallingInfoFlag<CodeGenOpts<"DisableNoundefAttrs">>;
54035402
def discard_value_names : Flag<["-"], "discard-value-names">,
54045403
HelpText<"Discard value names in LLVM IR">,
54055404
MarshallingInfoFlag<CodeGenOpts<"DiscardValueNames">>;

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
22432243
getLangOpts().Sanitize.has(SanitizerKind::Return);
22442244

22452245
// Determine if the return type could be partially undef
2246-
if (CodeGenOpts.EnableNoundefAttrs && HasStrictReturn) {
2246+
if (!CodeGenOpts.DisableNoundefAttrs && HasStrictReturn) {
22472247
if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
22482248
DetermineNoUndef(RetTy, getTypes(), DL, RetAI))
22492249
RetAttrs.addAttribute(llvm::Attribute::NoUndef);
@@ -2377,7 +2377,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
23772377
}
23782378

23792379
// Decide whether the argument we're handling could be partially undef
2380-
if (CodeGenOpts.EnableNoundefAttrs &&
2380+
if (!CodeGenOpts.DisableNoundefAttrs &&
23812381
DetermineNoUndef(ParamType, getTypes(), DL, AI)) {
23822382
Attrs.addAttribute(llvm::Attribute::NoUndef);
23832383
}

clang/test/CXX/except/except.spec/p14-ir.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ struct X4 {
2626
struct X5 : X0, X4 { };
2727

2828
void test(X2 x2, X3 x3, X5 x5) {
29-
// CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* {{[^,]*}} %this, %struct.X2* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
29+
// CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* {{[^,]*}} %this, %struct.X2* noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
3030
// CHECK: call void @_ZN2X2C2ERKS_({{.*}}) [[NUW:#[0-9]+]]
3131
// CHECK-NEXT: ret void
3232
// CHECK-NEXT: }
3333
X2 x2a(x2);
34-
// CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* {{[^,]*}} %this, %struct.X3* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
34+
// CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* {{[^,]*}} %this, %struct.X3* noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
3535
// CHECK: call void @_ZN2X3C2ERKS_({{.*}}) [[NUW]]
3636
// CHECK-NEXT: ret void
3737
// CHECK-NEXT: }

clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ bool f1(int *x) {
1313
return outer();
1414
}
1515

16-
// CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke
17-
// CHECK: call zeroext i1 @"_ZZZN7PR127462f1EPiEUb_ENK3$_0clEv"
16+
// CHECK: define internal noundef zeroext i1 @___ZN7PR127462f1EPi_block_invoke
17+
// CHECK: call noundef zeroext i1 @"_ZZZN7PR127462f1EPiEUb_ENK3$_0clEv"
1818

1919
bool f2(int *x) {
2020
auto outer = [&]() -> bool {

clang/test/CodeGen/2005-01-02-ConstantInits.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ int i = (int) &( ((struct X *)0) -> a[1]);
2929
int Arr[100];
3030

3131
// CHECK-LABEL: define {{[^@]+}}@foo
32-
// CHECK-SAME: (i32 [[I:%.*]]) #[[ATTR0]] {
32+
// CHECK-SAME: (i32 noundef [[I:%.*]]) #[[ATTR0]] {
3333
// CHECK-NEXT: entry:
3434
// CHECK-NEXT: [[I_ADDR:%.*]] = alloca i32, align 4
3535
// CHECK-NEXT: store i32 [[I]], i32* [[I_ADDR]], align 4
36-
// CHECK-NEXT: [[CALL:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* getelementptr inbounds ([100 x i32], [100 x i32]* @Arr, i64 0, i64 49))
36+
// CHECK-NEXT: [[CALL:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* noundef getelementptr inbounds ([100 x i32], [100 x i32]* @Arr, i64 0, i64 49))
3737
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[I_ADDR]], align 4
3838
// CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP0]] to i64
3939
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* @Arr, i64 0, i64 [[IDXPROM]]
40-
// CHECK-NEXT: [[CALL1:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* [[ARRAYIDX]])
40+
// CHECK-NEXT: [[CALL1:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* noundef [[ARRAYIDX]])
4141
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], [[CALL1]]
4242
// CHECK-NEXT: ret i32 [[ADD]]
4343
//
4444
int foo(int i) { return bar(&Arr[49])+bar(&Arr[i]); }
4545
// CHECK-LABEL: define {{[^@]+}}@foo2
46-
// CHECK-SAME: (i32 [[I:%.*]]) #[[ATTR0]] {
46+
// CHECK-SAME: (i32 noundef [[I:%.*]]) #[[ATTR0]] {
4747
// CHECK-NEXT: entry:
4848
// CHECK-NEXT: [[I_ADDR:%.*]] = alloca i32, align 4
4949
// CHECK-NEXT: [[P:%.*]] = alloca i32*, align 8
@@ -55,7 +55,7 @@ int foo(int i) { return bar(&Arr[49])+bar(&Arr[i]); }
5555
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[I_ADDR]], align 4
5656
// CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP1]] to i64
5757
// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @Arr, i64 0, i64 0), i64 [[IDX_EXT]]
58-
// CHECK-NEXT: [[CALL:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* [[ADD_PTR]])
58+
// CHECK-NEXT: [[CALL:%.*]] = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* noundef [[ADD_PTR]])
5959
// CHECK-NEXT: ret i32 [[CALL]]
6060
//
6161
int foo2(int i) {

clang/test/CodeGen/2006-05-19-SingleEltReturn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Y bar() {
2323
}
2424

2525

26-
// X86_32: define{{.*}} void @foo(%struct.Y* %P)
26+
// X86_32: define{{.*}} void @foo(%struct.Y* noundef %P)
2727
// X86_32: call void @bar(%struct.Y* sret(%struct.Y) align 4 %{{[^),]*}})
2828

2929
// X86_32: define{{.*}} void @bar(%struct.Y* noalias sret(%struct.Y) align 4 %{{[^,)]*}})

clang/test/CodeGen/2007-06-18-SextAttrAggregate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
1+
// RUN: %clang_cc1 -disable-noundef-analysis %s -o - -emit-llvm | FileCheck %s
22
// XFAIL: aarch64, arm64, x86_64-pc-windows-msvc, x86_64-w64-windows-gnu, x86_64-pc-windows-gnu
33

44
// PR1513

clang/test/CodeGen/2009-02-13-zerosize-union-field.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple i686-apple-darwin -emit-llvm -o - | FileCheck %s
1+
// RUN: %clang_cc1 %s -disable-noundef-analysis -triple i686-apple-darwin -emit-llvm -o - | FileCheck %s
22
// Every printf has 'i32 0' for the GEP of the string; no point counting those.
33
typedef unsigned int Foo __attribute__((aligned(32)));
44
typedef union{Foo:0;}a;

clang/test/CodeGen/2009-05-04-EnumInreg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin -mregparm 3 %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -disable-noundef-analysis -emit-llvm -triple i686-apple-darwin -mregparm 3 %s -o - | FileCheck %s
22
// PR3967
33

44
enum kobject_action {

0 commit comments

Comments
 (0)