[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.

GitOrigin-RevId: 1228becf7df28c68579f2b9b390b74aa41149a0a
diff --git a/test/COFF/savetemps.ll b/test/COFF/savetemps.ll
index 46a4958..64d0566 100644
--- a/test/COFF/savetemps.ll
+++ b/test/COFF/savetemps.ll
@@ -18,7 +18,7 @@
 ; RUN: llvm-objdump -s %T/savetemps/savetemps.exe.lto.obj | \
 ; RUN:     FileCheck --check-prefix=CHECK-OBJDUMP %s
 
-; CHECK: define i32 @main()
+; CHECK: define {{(noundef )?}}i32 @main()
 ; CHECK-OBJDUMP: file format coff
 
 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/test/ELF/lto/devirt_validate_vtable_typeinfos.ll b/test/ELF/lto/devirt_validate_vtable_typeinfos.ll
index 74e4377..eb2e997 100644
--- a/test/ELF/lto/devirt_validate_vtable_typeinfos.ll
+++ b/test/ELF/lto/devirt_validate_vtable_typeinfos.ll
@@ -183,7 +183,7 @@
 ;; Prevent the vtables from being dead code eliminated.
 @llvm.used = appending global [3 x ptr] [ ptr @_ZTV1B, ptr @_ZTV1C, ptr @_ZTV1D ]
 
-; CHECK-COMMON-IR-LABEL: define dso_local i32 @_start
+; CHECK-COMMON-IR-LABEL: define dso_local {{(noundef )?}}i32 @_start
 define i32 @_start(ptr %obj, ptr %obj2, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj
diff --git a/test/ELF/lto/devirt_validate_vtable_typeinfos_mixed_lto.ll b/test/ELF/lto/devirt_validate_vtable_typeinfos_mixed_lto.ll
index 15040b8..9dacbc3 100644
--- a/test/ELF/lto/devirt_validate_vtable_typeinfos_mixed_lto.ll
+++ b/test/ELF/lto/devirt_validate_vtable_typeinfos_mixed_lto.ll
@@ -53,7 +53,7 @@
 ;; Prevent the vtables from being dead code eliminated.
 @llvm.used = appending global [3 x ptr] [ ptr @_ZTV1B, ptr @_ZTV1C, ptr @_ZTV1D ], section "llvm.metadata"
 
-; CHECK-COMMON-IR-LABEL: define dso_local i32 @_start
+; CHECK-COMMON-IR-LABEL: define dso_local noundef i32 @_start
 define i32 @_start(ptr %obj, ptr %obj2, i32 %a) {
   ;; Call function built with RegularLTO
   %RegularLTOResult = call i32 @RegularLTO(ptr %obj, i32 %a)
diff --git a/test/ELF/lto/devirt_validate_vtable_typeinfos_no_rtti.ll b/test/ELF/lto/devirt_validate_vtable_typeinfos_no_rtti.ll
index 3f3ea2c..2c6f63f 100644
--- a/test/ELF/lto/devirt_validate_vtable_typeinfos_no_rtti.ll
+++ b/test/ELF/lto/devirt_validate_vtable_typeinfos_no_rtti.ll
@@ -67,7 +67,7 @@
 ;; Prevent the vtables from being dead code eliminated.
 @llvm.used = appending global [3 x ptr] [ ptr @_ZTV1B, ptr @_ZTV1C, ptr @_ZTV1D ]
 
-; CHECK-COMMON-IR-LABEL: define dso_local i32 @_start
+; CHECK-COMMON-IR-LABEL: define dso_local {{(noundef )?}}i32 @_start
 define i32 @_start(ptr %obj, ptr %obj2, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj
diff --git a/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll b/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll
index 7686fa9..2a52c5a 100644
--- a/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll
+++ b/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll
@@ -130,7 +130,7 @@
 ;; Prevent the vtables from being dead code eliminated.
 @llvm.used = appending global [3 x ptr] [ ptr @_ZTV1B, ptr @_ZTV1C, ptr @_ZTV1D]
 
-; CHECK-IR-LABEL: define dso_local i32 @_start
+; CHECK-IR-LABEL: define dso_local {{(noundef )?}}i32 @_start
 define i32 @_start(ptr %obj, ptr %obj2, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj
diff --git a/test/ELF/lto/devirt_vcall_vis_public.ll b/test/ELF/lto/devirt_vcall_vis_public.ll
index 1c0d55f..a827fea 100644
--- a/test/ELF/lto/devirt_vcall_vis_public.ll
+++ b/test/ELF/lto/devirt_vcall_vis_public.ll
@@ -65,7 +65,7 @@
 ; Prevent the vtables from being dead code eliminated.
 @llvm.used = appending global [3 x ptr] [ ptr @_ZTV1B, ptr @_ZTV1C, ptr @_ZTV1D]
 
-; CHECK-IR-LABEL: define dso_local i32 @_start
+; CHECK-IR-LABEL: define dso_local {{(noundef )?}}i32 @_start
 define i32 @_start(ptr %obj, ptr %obj2, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj