diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2023-12-31 20:44:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-31 20:44:48 +0800 |
commit | 1228becf7df28c68579f2b9b390b74aa41149a0a (patch) | |
tree | 6724c63cc31951d53e36f99aaaaaa6db136f2333 /llvm/test/ThinLTO | |
parent | c7c912cff945033918367c4a37121dfc09b9759e (diff) | |
download | llvm-1228becf7df28c68579f2b9b390b74aa41149a0a.zip llvm-1228becf7df28c68579f2b9b390b74aa41149a0a.tar.gz llvm-1228becf7df28c68579f2b9b390b74aa41149a0a.tar.bz2 |
[FuncAttrs] Deduce `noundef` attributes for return values (#76553)
This patch deduces `noundef` attributes for return values.
IIUC, a function returns `noundef` values iff all of its return values
are guaranteed not to be `undef` or `poison`.
Definition of `noundef` from LangRef:
```
noundef
This attribute applies to parameters and return values. If the value representation contains any
undefined or poison bits, the behavior is undefined. Note that this does not refer to padding
introduced by the type’s storage representation.
```
Alive2: https://alive2.llvm.org/ce/z/g8Eis6
Compile-time impact: http://llvm-compile-time-tracker.com/compare.php?from=30dcc33c4ea3ab50397a7adbe85fe977d4a400bd&to=c5e8738d4bfbf1e97e3f455fded90b791f223d74&stat=instructions:u
|stage1-O3|stage1-ReleaseThinLTO|stage1-ReleaseLTO-g|stage1-O0-g|stage2-O3|stage2-O0-g|stage2-clang|
|--|--|--|--|--|--|--|
|+0.01%|+0.01%|-0.01%|+0.01%|+0.03%|-0.04%|+0.01%|
The motivation of this patch is to reduce the number of `freeze` insts
and enable more optimizations.
Diffstat (limited to 'llvm/test/ThinLTO')
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt2.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_check.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_promote.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_promote_legacy.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_single_hybrid.ll | 4 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll | 4 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/funcimport.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/globals-import-const-fold.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/import-constant.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/index-const-prop-alias.ll | 2 | ||||
-rw-r--r-- | llvm/test/ThinLTO/X86/index-const-prop.ll | 2 |
14 files changed, 16 insertions, 16 deletions
diff --git a/llvm/test/ThinLTO/X86/devirt.ll b/llvm/test/ThinLTO/X86/devirt.ll index 3bb5d6b2..472e43d 100644 --- a/llvm/test/ThinLTO/X86/devirt.ll +++ b/llvm/test/ThinLTO/X86/devirt.ll @@ -100,7 +100,7 @@ target triple = "x86_64-grtev4-linux-gnu" @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3 -; CHECK-IR-LABEL: define i32 @test +; CHECK-IR-LABEL: define {{(noundef )?}}i32 @test define i32 @test(ptr %obj, ptr %obj2, i32 %a) { entry: %vtable = load ptr, ptr %obj diff --git a/llvm/test/ThinLTO/X86/devirt2.ll b/llvm/test/ThinLTO/X86/devirt2.ll index 1b33741..9e91efe 100644 --- a/llvm/test/ThinLTO/X86/devirt2.ll +++ b/llvm/test/ThinLTO/X86/devirt2.ll @@ -202,7 +202,7 @@ entry: ; CHECK-IR1-LABEL: ret i32 ; CHECK-IR1-LABEL: } -; CHECK-IR2: define i32 @test2 +; CHECK-IR2: define noundef i32 @test2 ; CHECK-IR2-NEXT: entry: ; Check that the call was devirtualized. Ignore extra character before ; symbol name which would happen if it was promoted during module diff --git a/llvm/test/ThinLTO/X86/devirt_check.ll b/llvm/test/ThinLTO/X86/devirt_check.ll index bf03afa..74f1dfd 100644 --- a/llvm/test/ThinLTO/X86/devirt_check.ll +++ b/llvm/test/ThinLTO/X86/devirt_check.ll @@ -40,7 +40,7 @@ target triple = "x86_64-grtev4-linux-gnu" @_ZTV1B = constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B1fEi to i8*), i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A1nEi to i8*)] }, !type !0, !type !1, !vcall_visibility !5 -; CHECK-LABEL: define i32 @test +; CHECK-LABEL: define {{(noundef )?}}i32 @test define i32 @test(%struct.A* %obj, i32 %a) { entry: %0 = bitcast %struct.A* %obj to i8*** diff --git a/llvm/test/ThinLTO/X86/devirt_promote.ll b/llvm/test/ThinLTO/X86/devirt_promote.ll index fc2b41f..d00701b 100644 --- a/llvm/test/ThinLTO/X86/devirt_promote.ll +++ b/llvm/test/ThinLTO/X86/devirt_promote.ll @@ -63,7 +63,7 @@ entry: ; CHECK-IR1-LABEL: ret i32 ; CHECK-IR1-LABEL: } -; CHECK-IR2: define i32 @test2 +; CHECK-IR2: define noundef i32 @test2 ; Check that the call was devirtualized. ; CHECK-IR2: %call4 = tail call i32 @_ZN1A1nEi diff --git a/llvm/test/ThinLTO/X86/devirt_promote_legacy.ll b/llvm/test/ThinLTO/X86/devirt_promote_legacy.ll index 9d7a402..542c1e8 100644 --- a/llvm/test/ThinLTO/X86/devirt_promote_legacy.ll +++ b/llvm/test/ThinLTO/X86/devirt_promote_legacy.ll @@ -45,7 +45,7 @@ entry: ; CHECK-IR1-LABEL: ret i32 ; CHECK-IR1-LABEL: } -; CHECK-IR2: define i32 @test2 +; CHECK-IR2: define noundef i32 @test2 ; Check that the call was devirtualized. ; CHECK-IR2: = tail call i32 @_ZN1A1nEi diff --git a/llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll b/llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll index cff6160..ea69eed 100644 --- a/llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll +++ b/llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll @@ -66,7 +66,7 @@ target triple = "x86_64-grtev4-linux-gnu" ;; Prevent the vtables from being dead code eliminated. @llvm.used = appending global [2 x ptr] [ ptr @_ZTV1A, ptr @_ZTV1B] -; CHECK-IR-LABEL: define dso_local i32 @_start +; CHECK-IR-LABEL: define dso_local {{(noundef )?}}i32 @_start define i32 @_start(ptr %obj, i32 %a) { entry: %vtable = load ptr, ptr %obj diff --git a/llvm/test/ThinLTO/X86/devirt_single_hybrid.ll b/llvm/test/ThinLTO/X86/devirt_single_hybrid.ll index f5a3755..90fdf0d 100644 --- a/llvm/test/ThinLTO/X86/devirt_single_hybrid.ll +++ b/llvm/test/ThinLTO/X86/devirt_single_hybrid.ll @@ -24,11 +24,11 @@ ; REMARK-COUNT-3: single-impl: devirtualized a call to _ZNK1A1fEv -; IMPORT: define available_externally hidden i32 @_ZNK1A1fEv(ptr %this) +; IMPORT: define available_externally hidden {{(noundef )?}}i32 @_ZNK1A1fEv(ptr %this) ; IMPORT-NEXT: entry: ; IMPORT-NEXT: ret i32 3 -; CODEGEN: define hidden i32 @main() +; CODEGEN: define hidden {{(noundef )?}}i32 @main() ; CODEGEN-NEXT: entry: ; CODEGEN-NEXT: ret i32 23 diff --git a/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll b/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll index 7ebb22c..7c007e1 100644 --- a/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll +++ b/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll @@ -71,7 +71,7 @@ target triple = "x86_64-grtev4-linux-gnu" @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3, !vcall_visibility !5 -; CHECK-IR-LABEL: define i32 @test +; CHECK-IR-LABEL: define {{(noundef )?}}i32 @test define i32 @test(ptr %obj, ptr %obj2, i32 %a) { entry: %vtable = load ptr, ptr %obj diff --git a/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll b/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll index 10dda3f..dfb2f8f 100644 --- a/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll +++ b/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll @@ -157,7 +157,7 @@ target triple = "x86_64-grtev4-linux-gnu" @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3, !vcall_visibility !5 -; CHECK-IR-LABEL: define i32 @test +; CHECK-IR-LABEL: define {{(noundef )?}}i32 @test define i32 @test(ptr %obj, ptr %obj2, i32 %a) { entry: %vtable = load ptr, ptr %obj @@ -193,7 +193,7 @@ entry: ; CHECK-IR-LABEL: ret i32 ; CHECK-IR-LABEL: } -; CHECK-IR-LABEL: define i32 @test_public +; CHECK-IR-LABEL: define {{(noundef )?}}i32 @test_public define i32 @test_public(ptr %obj, ptr %obj2, i32 %a) { entry: %vtable = load ptr, ptr %obj diff --git a/llvm/test/ThinLTO/X86/funcimport.ll b/llvm/test/ThinLTO/X86/funcimport.ll index 63a83b6..3f7941b 100644 --- a/llvm/test/ThinLTO/X86/funcimport.ll +++ b/llvm/test/ThinLTO/X86/funcimport.ll @@ -33,7 +33,7 @@ ; Verify that the optimizer run ; RUN: llvm-lto -thinlto-action=optimize %t2.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=OPTIMIZED -; OPTIMIZED: define i32 @main() +; OPTIMIZED: define noundef i32 @main() ; Verify that the codegen run ; RUN: llvm-lto -thinlto-action=codegen %t2.bc -o - | llvm-nm -o - | FileCheck %s --check-prefix=CODEGEN diff --git a/llvm/test/ThinLTO/X86/globals-import-const-fold.ll b/llvm/test/ThinLTO/X86/globals-import-const-fold.ll index ec94719..caa0103 100644 --- a/llvm/test/ThinLTO/X86/globals-import-const-fold.ll +++ b/llvm/test/ThinLTO/X86/globals-import-const-fold.ll @@ -9,7 +9,7 @@ ; IMPORT: @baz = internal local_unnamed_addr constant i32 10 -; OPTIMIZE: define i32 @main() +; OPTIMIZE: define noundef i32 @main() ; OPTIMIZE-NEXT: ret i32 10 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/ThinLTO/X86/import-constant.ll b/llvm/test/ThinLTO/X86/import-constant.ll index 79d0ef5..a614fd9 100644 --- a/llvm/test/ThinLTO/X86/import-constant.ll +++ b/llvm/test/ThinLTO/X86/import-constant.ll @@ -35,7 +35,7 @@ ; @outer is a write-only variable that's stored to once, so the store and the global can be removed. ; OPT-NOT: @outer -; OPT: define dso_local i32 @main() +; OPT: define dso_local noundef i32 @main() ; OPT-NEXT: entry: ; OPT-NEXT: ret i32 12 diff --git a/llvm/test/ThinLTO/X86/index-const-prop-alias.ll b/llvm/test/ThinLTO/X86/index-const-prop-alias.ll index 1e4855a..91d3118 100644 --- a/llvm/test/ThinLTO/X86/index-const-prop-alias.ll +++ b/llvm/test/ThinLTO/X86/index-const-prop-alias.ll @@ -20,7 +20,7 @@ ; IMPORT-NEXT: @g = internal global i32 42, align 4 #0 ; IMPORT: attributes #0 = { "thinlto-internalize" } -; CODEGEN: define dso_local i32 @main +; CODEGEN: define dso_local noundef i32 @main ; CODEGEN-NEXT: ret i32 42 ; PRESERVED: @g.alias = external global i32 diff --git a/llvm/test/ThinLTO/X86/index-const-prop.ll b/llvm/test/ThinLTO/X86/index-const-prop.ll index 5087ec6..f55fc23d 100644 --- a/llvm/test/ThinLTO/X86/index-const-prop.ll +++ b/llvm/test/ThinLTO/X86/index-const-prop.ll @@ -23,7 +23,7 @@ ; IMPORT-NEXT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4, !dbg !5 ; IMPORT: !DICompileUnit({{.*}}) -; OPTIMIZE: define i32 @main +; OPTIMIZE: define noundef i32 @main ; OPTIMIZE-NEXT: ret i32 3 ; IMPORT2: @gBar = available_externally local_unnamed_addr global i32 2, align 4, !dbg !0 |