[clang] [HLSL] Change default linkage of HLSL functions to internal (PR #93336)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 7 14:29:45 PDT 2024


https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/93336

>From 578bfcdb668ec3702fba13cac7ff025d6337608d Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 24 May 2024 12:35:02 -0700
Subject: [PATCH 1/4] [HLSL] Change default linkage of HLSL functions to
 internal

Fixes #92071
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp           |  15 ++
 clang/lib/CodeGen/CGHLSLRuntime.h             |   7 +-
 clang/lib/CodeGen/CodeGenFunction.cpp         |   7 +-
 clang/test/CodeGenHLSL/ArrayTemporary.hlsl    |  12 +-
 clang/test/CodeGenHLSL/builtins/abs.hlsl      |  56 +++---
 clang/test/CodeGenHLSL/builtins/all.hlsl      | 160 +++++++++---------
 clang/test/CodeGenHLSL/builtins/any.hlsl      | 160 +++++++++---------
 clang/test/CodeGenHLSL/builtins/ceil.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/clamp.hlsl    |  80 ++++-----
 clang/test/CodeGenHLSL/builtins/cos.hlsl      |  24 +--
 clang/test/CodeGenHLSL/builtins/exp.hlsl      |  24 +--
 clang/test/CodeGenHLSL/builtins/exp2.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/floor.hlsl    |  24 +--
 clang/test/CodeGenHLSL/builtins/frac.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/isinf.hlsl    |  16 +-
 clang/test/CodeGenHLSL/builtins/log.hlsl      |  24 +--
 clang/test/CodeGenHLSL/builtins/log10.hlsl    |  24 +--
 clang/test/CodeGenHLSL/builtins/log2.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/max.hlsl      |  80 ++++-----
 clang/test/CodeGenHLSL/builtins/min.hlsl      |  80 ++++-----
 clang/test/CodeGenHLSL/builtins/pow.hlsl      |  24 +--
 clang/test/CodeGenHLSL/builtins/rcp.hlsl      |  64 +++----
 .../CodeGenHLSL/builtins/reversebits.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/round.hlsl    |  24 +--
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl    |  24 +--
 clang/test/CodeGenHLSL/builtins/sin.hlsl      |  24 +--
 clang/test/CodeGenHLSL/builtins/sqrt.hlsl     |  24 +--
 clang/test/CodeGenHLSL/builtins/trunc.hlsl    |  24 +--
 .../wave_get_lane_index_do_while.hlsl         |   2 +-
 .../builtins/wave_get_lane_index_simple.hlsl  |   2 +-
 .../builtins/wave_get_lane_index_subcall.hlsl |   4 +-
 .../CodeGenHLSL/convergence/do.while.hlsl     |  10 +-
 clang/test/CodeGenHLSL/convergence/for.hlsl   |  14 +-
 clang/test/CodeGenHLSL/convergence/while.hlsl |  12 +-
 clang/test/CodeGenHLSL/no_int_promotion.hlsl  |  14 +-
 clang/test/CodeGenHLSL/shift-mask.hlsl        |   8 +-
 .../CodeGenHLSL/this-assignment-overload.hlsl |   4 +-
 clang/test/CodeGenHLSL/this-assignment.hlsl   |   4 +-
 .../enable_16bit_types_validation_spirv.hlsl  |   2 +-
 39 files changed, 606 insertions(+), 591 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 5e6a3dd4878f4..0f18c55adaab4 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -353,6 +353,21 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
   return nullptr;
 }
 
+void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD,
+                                      llvm::Function *Fn) {
+  if (!FD || !Fn)
+    return;
+
+  if (FD->hasAttr<HLSLShaderAttr>()) {
+    emitEntryFunction(FD, Fn);
+  } else {
+    // HLSL functions that are not shader entry points or exported
+    // have internal linkage by default.
+    // FIXME: skip this for exported functions (Issue #92812)
+    Fn->setLinkage(GlobalValue::InternalLinkage);
+  }
+}
+
 void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
                                       llvm::Function *Fn) {
   llvm::Module &M = CGM.getModule();
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h
index 0abe39dedcb96..4ffb5c00dd115 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -116,12 +116,11 @@ class CGHLSLRuntime {
   void addBuffer(const HLSLBufferDecl *D);
   void finishCodeGen();
 
-  void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
-
-  void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
-  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
+  void emitFunctionProlog(const FunctionDecl *FD, llvm::Function *Fn);
 
 private:
+  void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
+  void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
   void addBufferResourceAnnotation(llvm::GlobalVariable *GV,
                                    llvm::hlsl::ResourceClass RC,
                                    llvm::hlsl::ResourceKind RK, bool IsROV,
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index f0345f3b191b8..3ef21aa9c5b2b 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1194,9 +1194,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
     CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  // Handle emitting HLSL entry functions.
-  if (D && D->hasAttr<HLSLShaderAttr>())
-    CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+  // Emit HLSL specific initialization
+  if (getLangOpts().HLSL) {
+    CGM.getHLSLRuntime().emitFunctionProlog(FD, Fn);
+  }
 
   EmitFunctionProlog(*CurFnInfo, CurFn, Args);
 
diff --git a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
index 63a30b61440eb..07076f72405f3 100644
--- a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
@@ -2,7 +2,7 @@
 
 void fn(float x[2]) { }
 
-// CHECK-LABEL: define void {{.*}}call{{.*}}
+// CHECK-LABEL: define internal void {{.*}}call{{.*}}
 // CHECK: [[Arr:%.*]] = alloca [2 x float]
 // CHECK: [[Tmp:%.*]] = alloca [2 x float]
 // CHECK: call void @llvm.memset.p0.i32(ptr align 4 [[Arr]], i8 0, i32 8, i1 false)
@@ -20,7 +20,7 @@ struct Obj {
 
 void fn2(Obj O[4]) { }
 
-// CHECK-LABEL: define void {{.*}}call2{{.*}}
+// CHECK-LABEL: define internal void {{.*}}call2{{.*}}
 // CHECK: [[Arr:%.*]] = alloca [4 x %struct.Obj]
 // CHECK: [[Tmp:%.*]] = alloca [4 x %struct.Obj]
 // CHECK: call void @llvm.memset.p0.i32(ptr align 4 [[Arr]], i8 0, i32 32, i1 false)
@@ -34,7 +34,7 @@ void call2() {
 
 void fn3(float x[2][2]) { }
 
-// CHECK-LABEL: define void {{.*}}call3{{.*}}
+// CHECK-LABEL: define internal void {{.*}}call3{{.*}}
 // CHECK: [[Arr:%.*]] = alloca [2 x [2 x float]]
 // CHECK: [[Tmp:%.*]] = alloca [2 x [2 x float]]
 // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Arr]], ptr align 4 {{.*}}, i32 16, i1 false)
@@ -45,7 +45,7 @@ void call3() {
   fn3(Arr);
 }
 
-// CHECK-LABEL: define void {{.*}}call4{{.*}}(ptr
+// CHECK-LABEL: define internal void {{.*}}call4{{.*}}(ptr
 // CHECK-SAME: noundef byval([2 x [2 x float]]) align 4 [[Arr:%.*]])
 // CHECK: [[Tmp:%.*]] = alloca [2 x [2 x float]]
 // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[Arr]], i32 16, i1 false)
@@ -58,7 +58,7 @@ void call4(float Arr[2][2]) {
 // Verify that each template instantiation codegens to a unique and correctly
 // mangled function name.
 
-// CHECK-LABEL: define void {{.*}}template_call{{.*}}(ptr
+// CHECK-LABEL: define internal void {{.*}}template_call{{.*}}(ptr
 
 // CHECK-SAME: noundef byval([2 x float]) align 4 [[FA2:%[0-9A-Z]+]],
 // CHECK-SAME: ptr noundef byval([4 x float]) align 4 [[FA4:%[0-9A-Z]+]],
@@ -85,7 +85,7 @@ void template_call(float FA2[2], float FA4[4], int IA3[3]) {
 
 
 // Verify that Array parameter element access correctly codegens.
-// CHECK-LABEL: define void {{.*}}element_access{{.*}}(ptr
+// CHECK-LABEL: define internal void {{.*}}element_access{{.*}}(ptr
 // CHECK-SAME: noundef byval([2 x float]) align 4 [[FA2:%[0-9A-Z]+]]
 
 // CHECK: [[Addr:%.*]] = getelementptr inbounds [2 x float], ptr [[FA2]], i32 0, i32 0
diff --git a/clang/test/CodeGenHLSL/builtins/abs.hlsl b/clang/test/CodeGenHLSL/builtins/abs.hlsl
index ad65cab2721a2..1a38d9b6f6f7b 100644
--- a/clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -9,85 +9,85 @@
 using hlsl::abs;
 
 #ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.abs.i16(
 int16_t test_abs_int16_t(int16_t p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.abs.v2i16(
 int16_t2 test_abs_int16_t2(int16_t2 p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.abs.v3i16(
 int16_t3 test_abs_int16_t3(int16_t3 p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.abs.v4i16(
 int16_t4 test_abs_int16_t4(int16_t4 p0) { return abs(p0); }
 #endif // __HLSL_ENABLE_16_BIT
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.fabs.f16(
-// NO_HALF: define noundef float @"?test_abs_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_abs_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.fabs.f32(float %0)
 half test_abs_half(half p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.fabs.v2f16(
-// NO_HALF: define noundef <2 x float> @"?test_abs_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <2 x float> @"?test_abs_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
 // NO_HALF: call <2 x float> @llvm.fabs.v2f32(
 half2 test_abs_half2(half2 p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.fabs.v3f16(
-// NO_HALF: define noundef <3 x float> @"?test_abs_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <3 x float> @"?test_abs_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
 // NO_HALF: call <3 x float> @llvm.fabs.v3f32(
 half3 test_abs_half3(half3 p0) { return abs(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.fabs.v4f16(
-// NO_HALF: define noundef <4 x float> @"?test_abs_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <4 x float> @"?test_abs_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
 // NO_HALF: call <4 x float> @llvm.fabs.v4f32(
 half4 test_abs_half4(half4 p0) { return abs(p0); }
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.abs.i32(
 int test_abs_int(int p0) { return abs(p0); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.abs.v2i32(
 int2 test_abs_int2(int2 p0) { return abs(p0); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.abs.v3i32(
 int3 test_abs_int3(int3 p0) { return abs(p0); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.abs.v4i32(
 int4 test_abs_int4(int4 p0) { return abs(p0); }
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: call float @llvm.fabs.f32(
 float test_abs_float(float p0) { return abs(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: call <2 x float> @llvm.fabs.v2f32(
 float2 test_abs_float2(float2 p0) { return abs(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: call <3 x float> @llvm.fabs.v3f32(
 float3 test_abs_float3(float3 p0) { return abs(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: call <4 x float> @llvm.fabs.v4f32(
 float4 test_abs_float4(float4 p0) { return abs(p0); }
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.abs.i64(
 int64_t test_abs_int64_t(int64_t p0) { return abs(p0); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.abs.v2i64(
 int64_t2 test_abs_int64_t2(int64_t2 p0) { return abs(p0); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.abs.v3i64(
 int64_t3 test_abs_int64_t3(int64_t3 p0) { return abs(p0); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.abs.v4i64(
 int64_t4 test_abs_int64_t4(int64_t4 p0) { return abs(p0); }
-// CHECK: define noundef double @
+// CHECK: define internal noundef double @
 // CHECK: call double @llvm.fabs.f64(
 double test_abs_double(double p0) { return abs(p0); }
-// CHECK: define noundef <2 x double> @
+// CHECK: define internal noundef <2 x double> @
 // CHECK: call <2 x double> @llvm.fabs.v2f64(
 double2 test_abs_double2(double2 p0) { return abs(p0); }
-// CHECK: define noundef <3 x double> @
+// CHECK: define internal noundef <3 x double> @
 // CHECK: call <3 x double> @llvm.fabs.v3f64(
 double3 test_abs_double3(double3 p0) { return abs(p0); }
-// CHECK: define noundef <4 x double> @
+// CHECK: define internal noundef <4 x double> @
 // CHECK: call <4 x double> @llvm.fabs.v4f64(
 double4 test_abs_double4(double4 p0) { return abs(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480f..8437199a7da52 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -14,59 +14,59 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t(uint16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t2(uint16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t3(uint16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t4(uint16_t4 p0) { return all(p0); }
 #endif // __HLSL_ENABLE_16_BIT
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.f16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.f16
 // DXIL_NO_HALF: %hlsl.all = call i1 @llvm.dx.all.f32
@@ -74,8 +74,8 @@ bool test_all_uint16_t4(uint16_t4 p0) { return all(p0); }
 // CHECK: ret i1 %hlsl.all
 bool test_all_half(half p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2f16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2f16
 // DXIL_NO_HALF: %hlsl.all = call i1 @llvm.dx.all.v2f32
@@ -83,8 +83,8 @@ bool test_all_half(half p0) { return all(p0); }
 // CHECK: ret i1 %hlsl.all
 bool test_all_half2(half2 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3f16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3f16
 // DXIL_NO_HALF: %hlsl.all = call i1 @llvm.dx.all.v3f32
@@ -92,8 +92,8 @@ bool test_all_half2(half2 p0) { return all(p0); }
 // CHECK: ret i1 %hlsl.all
 bool test_all_half3(half3 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4f16
 // SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4f16
 // DXIL_NO_HALF: %hlsl.all = call i1 @llvm.dx.all.v4f32
@@ -101,176 +101,176 @@ bool test_all_half3(half3 p0) { return all(p0); }
 // CHECK: ret i1 %hlsl.all
 bool test_all_half4(half4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.f32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.f32
 // CHECK: ret i1 %hlsl.all
 bool test_all_float(float p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2f32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2f32
 // CHECK: ret i1 %hlsl.all
 bool test_all_float2(float2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3f32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3f32
 // CHECK: ret i1 %hlsl.all
 bool test_all_float3(float3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4f32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4f32
 // CHECK: ret i1 %hlsl.all
 bool test_all_float4(float4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.f64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.f64
 // CHECK: ret i1 %hlsl.all
 bool test_all_double(double p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2f64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2f64
 // CHECK: ret i1 %hlsl.all
 bool test_all_double2(double2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3f64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3f64
 // CHECK: ret i1 %hlsl.all
 bool test_all_double3(double3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4f64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4f64
 // CHECK: ret i1 %hlsl.all
 bool test_all_double4(double4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_int(int p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_int2(int2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_int3(int3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_int4(int4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint(uint p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint2(uint2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint3(uint3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4i32
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4i32
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint4(uint4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_int64_t(int64_t p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_int64_t2(int64_t2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_int64_t3(int64_t3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_int64_t4(int64_t4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint64_t(uint64_t p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint64_t2(uint64_t2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint64_t3(uint64_t3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4i64
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4i64
 // CHECK: ret i1 %hlsl.all
 bool test_all_uint64_t4(uint64_t4 p0) { return all(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.i1
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.i1
 // CHECK: ret i1 %hlsl.all
 bool test_all_bool(bool p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v2i1
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v2i1
 // CHECK: ret i1 %hlsl.all
 bool test_all_bool2(bool2 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v3i1
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v3i1
 // CHECK: ret i1 %hlsl.all
 bool test_all_bool3(bool3 p0) { return all(p0); }
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.all = call i1 @llvm.dx.all.v4i1
 // SPIR_CHECK: %hlsl.all = call i1 @llvm.spv.all.v4i1
 // CHECK: ret i1 %hlsl.all
diff --git a/clang/test/CodeGenHLSL/builtins/any.hlsl b/clang/test/CodeGenHLSL/builtins/any.hlsl
index 84584281a3b7d..b4962ab30becc 100644
--- a/clang/test/CodeGenHLSL/builtins/any.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/any.hlsl
@@ -14,65 +14,65 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_int16_t(int16_t p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v2i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v2i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_int16_t2(int16_t2 p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v3i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v3i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_int16_t3(int16_t3 p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v4i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v4i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_int16_t4(int16_t4 p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_uint16_t(uint16_t p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v2i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v2i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_uint16_t2(uint16_t2 p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v3i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v3i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_uint16_t3(uint16_t3 p0) { return any(p0); }
 
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define internal noundef i1 @
+// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v4i16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v4i16
 // NATIVE_HALF: ret i1 %hlsl.any
 bool test_any_uint16_t4(uint16_t4 p0) { return any(p0); }
 #endif // __HLSL_ENABLE_16_BIT
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.f16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.f16
 // DXIL_NO_HALF: %hlsl.any = call i1 @llvm.dx.any.f32
@@ -80,8 +80,8 @@ bool test_any_uint16_t4(uint16_t4 p0) { return any(p0); }
 // CHECK: ret i1 %hlsl.any
 bool test_any_half(half p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v2f16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v2f16
 // DXIL_NO_HALF: %hlsl.any = call i1 @llvm.dx.any.v2f32
@@ -89,8 +89,8 @@ bool test_any_half(half p0) { return any(p0); }
 // CHECK: ret i1 %hlsl.any
 bool test_any_half2(half2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v3f16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v3f16
 // DXIL_NO_HALF: %hlsl.any = call i1 @llvm.dx.any.v3f32
@@ -98,8 +98,8 @@ bool test_any_half2(half2 p0) { return any(p0); }
 // CHECK: ret i1 %hlsl.any
 bool test_any_half3(half3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_NATIVE_HALF: %hlsl.any = call i1 @llvm.dx.any.v4f16
 // SPIR_NATIVE_HALF: %hlsl.any = call i1 @llvm.spv.any.v4f16
 // DXIL_NO_HALF: %hlsl.any = call i1 @llvm.dx.any.v4f32
@@ -107,197 +107,197 @@ bool test_any_half3(half3 p0) { return any(p0); }
 // CHECK: ret i1 %hlsl.any
 bool test_any_half4(half4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.f32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.f32
 // CHECK: ret i1 %hlsl.any
 bool test_any_float(float p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2f32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2f32
 // CHECK: ret i1 %hlsl.any
 bool test_any_float2(float2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3f32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3f32
 // CHECK: ret i1 %hlsl.any
 bool test_any_float3(float3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4f32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4f32
 // CHECK: ret i1 %hlsl.any
 bool test_any_float4(float4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.f64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.f64
 // CHECK: ret i1 %hlsl.any
 bool test_any_double(double p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2f64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2f64
 // CHECK: ret i1 %hlsl.any
 bool test_any_double2(double2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3f64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3f64
 // CHECK: ret i1 %hlsl.any
 bool test_any_double3(double3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4f64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4f64
 // CHECK: ret i1 %hlsl.any
 bool test_any_double4(double4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_int(int p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_int2(int2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_int3(int3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_int4(int4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint(uint p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint2(uint2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint3(uint3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4i32
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4i32
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint4(uint4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_int64_t(int64_t p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_int64_t2(int64_t2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_int64_t3(int64_t3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_int64_t4(int64_t4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint64_t(uint64_t p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint64_t2(uint64_t2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint64_t3(uint64_t3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4i64
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4i64
 // CHECK: ret i1 %hlsl.any
 bool test_any_uint64_t4(uint64_t4 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.i1
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.i1
 // CHECK: ret i1 %hlsl.any
 bool test_any_bool(bool p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v2i1
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v2i1
 // CHECK: ret i1 %hlsl.any
 bool test_any_bool2(bool2 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v3i1
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v3i1
 // CHECK: ret i1 %hlsl.any
 bool test_any_bool3(bool3 p0) { return any(p0); }
 
-// DXIL_CHECK: define noundef i1 @
-// SPIR_CHECK: define spir_func noundef i1 @
+// DXIL_CHECK: define internal noundef i1 @
+// SPIR_CHECK: define internal spir_func noundef i1 @
 // DXIL_CHECK: %hlsl.any = call i1 @llvm.dx.any.v4i1
 // SPIR_CHECK: %hlsl.any = call i1 @llvm.spv.any.v4i1
 // CHECK: ret i1 %hlsl.any
diff --git a/clang/test/CodeGenHLSL/builtins/ceil.hlsl b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
index be7725cd4d66c..ee6ecdc77f386 100644
--- a/clang/test/CodeGenHLSL/builtins/ceil.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
@@ -8,36 +8,36 @@
 
 using hlsl::ceil;
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.ceil.f16(
-// NO_HALF: define noundef float @"?test_ceil_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_ceil_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.ceil.f32(float %0)
 half test_ceil_half(half p0) { return ceil(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.ceil.v2f16(
-// NO_HALF: define noundef <2 x float> @"?test_ceil_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <2 x float> @"?test_ceil_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
 // NO_HALF: call <2 x float> @llvm.ceil.v2f32(
 half2 test_ceil_half2(half2 p0) { return ceil(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.ceil.v3f16(
-// NO_HALF: define noundef <3 x float> @"?test_ceil_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <3 x float> @"?test_ceil_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
 // NO_HALF: call <3 x float> @llvm.ceil.v3f32(
 half3 test_ceil_half3(half3 p0) { return ceil(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.ceil.v4f16(
-// NO_HALF: define noundef <4 x float> @"?test_ceil_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <4 x float> @"?test_ceil_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
 // NO_HALF: call <4 x float> @llvm.ceil.v4f32(
 half4 test_ceil_half4(half4 p0) { return ceil(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: call float @llvm.ceil.f32(
 float test_ceil_float(float p0) { return ceil(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: call <2 x float> @llvm.ceil.v2f32(
 float2 test_ceil_float2(float2 p0) { return ceil(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: call <3 x float> @llvm.ceil.v3f32(
 float3 test_ceil_float3(float3 p0) { return ceil(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: call <4 x float> @llvm.ceil.v4f32(
 float4 test_ceil_float4(float4 p0) { return ceil(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/clamp.hlsl b/clang/test/CodeGenHLSL/builtins/clamp.hlsl
index 186114581e9c1..521b89b82f07c 100644
--- a/clang/test/CodeGenHLSL/builtins/clamp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/clamp.hlsl
@@ -7,128 +7,128 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
 #ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.dx.clamp.i16(
 int16_t test_clamp_short(int16_t p0, int16_t p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.dx.clamp.v2i16(
 int16_t2 test_clamp_short2(int16_t2 p0, int16_t2 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.dx.clamp.v3i16
 int16_t3 test_clamp_short3(int16_t3 p0, int16_t3 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.dx.clamp.v4i16
 int16_t4 test_clamp_short4(int16_t4 p0, int16_t4 p1) { return clamp(p0, p1,p1); }
 
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.dx.uclamp.i16(
 uint16_t test_clamp_ushort(uint16_t p0, uint16_t p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.dx.uclamp.v2i16
 uint16_t2 test_clamp_ushort2(uint16_t2 p0, uint16_t2 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.dx.uclamp.v3i16
 uint16_t3 test_clamp_ushort3(uint16_t3 p0, uint16_t3 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.dx.uclamp.v4i16
 uint16_t4 test_clamp_ushort4(uint16_t4 p0, uint16_t4 p1) { return clamp(p0, p1,p1); }
 #endif
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.dx.clamp.i32(
 int test_clamp_int(int p0, int p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.dx.clamp.v2i32
 int2 test_clamp_int2(int2 p0, int2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.dx.clamp.v3i32
 int3 test_clamp_int3(int3 p0, int3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.dx.clamp.v4i32
 int4 test_clamp_int4(int4 p0, int4 p1) { return clamp(p0, p1,p1); }
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.dx.uclamp.i32(
 int test_clamp_uint(uint p0, uint p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.dx.uclamp.v2i32
 uint2 test_clamp_uint2(uint2 p0, uint2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.dx.uclamp.v3i32
 uint3 test_clamp_uint3(uint3 p0, uint3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.dx.uclamp.v4i32
 uint4 test_clamp_uint4(uint4 p0, uint4 p1) { return clamp(p0, p1,p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.dx.clamp.i64(
 int64_t test_clamp_long(int64_t p0, int64_t p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.dx.clamp.v2i64
 int64_t2 test_clamp_long2(int64_t2 p0, int64_t2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.dx.clamp.v3i64
 int64_t3 test_clamp_long3(int64_t3 p0, int64_t3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.dx.clamp.v4i64
 int64_t4 test_clamp_long4(int64_t4 p0, int64_t4 p1) { return clamp(p0, p1,p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.dx.uclamp.i64(
 uint64_t test_clamp_long(uint64_t p0, uint64_t p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.dx.uclamp.v2i64
 uint64_t2 test_clamp_long2(uint64_t2 p0, uint64_t2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.dx.uclamp.v3i64
 uint64_t3 test_clamp_long3(uint64_t3 p0, uint64_t3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.dx.uclamp.v4i64
 uint64_t4 test_clamp_long4(uint64_t4 p0, uint64_t4 p1) { return clamp(p0, p1,p1); }
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.dx.clamp.f16(
-// NO_HALF: define noundef float @"?test_clamp_half
+// NO_HALF: define internal noundef float @"?test_clamp_half
 // NO_HALF: call float @llvm.dx.clamp.f32(
 half test_clamp_half(half p0, half p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.dx.clamp.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_clamp_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_clamp_half2
 // NO_HALF: call <2 x float> @llvm.dx.clamp.v2f32(
 half2 test_clamp_half2(half2 p0, half2 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.dx.clamp.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_clamp_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_clamp_half3
 // NO_HALF: call <3 x float> @llvm.dx.clamp.v3f32(
 half3 test_clamp_half3(half3 p0, half3 p1) { return clamp(p0, p1,p1); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.dx.clamp.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_clamp_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_clamp_half4
 // NO_HALF: call <4 x float> @llvm.dx.clamp.v4f32(
 half4 test_clamp_half4(half4 p0, half4 p1) { return clamp(p0, p1,p1); }
 
-// CHECK: define noundef float @"?test_clamp_float
+// CHECK: define internal noundef float @"?test_clamp_float
 // CHECK: call float @llvm.dx.clamp.f32(
 float test_clamp_float(float p0, float p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x float> @"?test_clamp_float2
+// CHECK: define internal noundef <2 x float> @"?test_clamp_float2
 // CHECK: call <2 x float> @llvm.dx.clamp.v2f32
 float2 test_clamp_float2(float2 p0, float2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x float> @"?test_clamp_float3
+// CHECK: define internal noundef <3 x float> @"?test_clamp_float3
 // CHECK: call <3 x float> @llvm.dx.clamp.v3f32
 float3 test_clamp_float3(float3 p0, float3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x float> @"?test_clamp_float4
+// CHECK: define internal noundef <4 x float> @"?test_clamp_float4
 // CHECK: call <4 x float> @llvm.dx.clamp.v4f32
 float4 test_clamp_float4(float4 p0, float4 p1) { return clamp(p0, p1,p1); }
 
-// CHECK: define noundef double @
+// CHECK: define internal noundef double @
 // CHECK: call double @llvm.dx.clamp.f64(
 double test_clamp_double(double p0, double p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <2 x double> @
+// CHECK: define internal noundef <2 x double> @
 // CHECK: call <2 x double> @llvm.dx.clamp.v2f64
 double2 test_clamp_double2(double2 p0, double2 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <3 x double> @
+// CHECK: define internal noundef <3 x double> @
 // CHECK: call <3 x double> @llvm.dx.clamp.v3f64
 double3 test_clamp_double3(double3 p0, double3 p1) { return clamp(p0, p1,p1); }
-// CHECK: define noundef <4 x double> @
+// CHECK: define internal noundef <4 x double> @
 // CHECK: call <4 x double> @llvm.dx.clamp.v4f64
 double4 test_clamp_double4(double4 p0, double4 p1) { return clamp(p0, p1,p1); }
diff --git a/clang/test/CodeGenHLSL/builtins/cos.hlsl b/clang/test/CodeGenHLSL/builtins/cos.hlsl
index 58b6309778813..84b722c421f64 100644
--- a/clang/test/CodeGenHLSL/builtins/cos.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/cos.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.cos.f16(
-// NO_HALF: define noundef float @"?test_cos_half
+// NO_HALF: define internal noundef float @"?test_cos_half
 // NO_HALF: call float @llvm.cos.f32(
 half test_cos_half(half p0) { return cos(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.cos.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_cos_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_cos_half2
 // NO_HALF: call <2 x float> @llvm.cos.v2f32(
 half2 test_cos_half2(half2 p0) { return cos(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.cos.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_cos_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_cos_half3
 // NO_HALF: call <3 x float> @llvm.cos.v3f32(
 half3 test_cos_half3(half3 p0) { return cos(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.cos.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_cos_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_cos_half4
 // NO_HALF: call <4 x float> @llvm.cos.v4f32(
 half4 test_cos_half4(half4 p0) { return cos(p0); }
 
-// CHECK: define noundef float @"?test_cos_float
+// CHECK: define internal noundef float @"?test_cos_float
 // CHECK: call float @llvm.cos.f32(
 float test_cos_float(float p0) { return cos(p0); }
-// CHECK: define noundef <2 x float> @"?test_cos_float2
+// CHECK: define internal noundef <2 x float> @"?test_cos_float2
 // CHECK: call <2 x float> @llvm.cos.v2f32
 float2 test_cos_float2(float2 p0) { return cos(p0); }
-// CHECK: define noundef <3 x float> @"?test_cos_float3
+// CHECK: define internal noundef <3 x float> @"?test_cos_float3
 // CHECK: call <3 x float> @llvm.cos.v3f32
 float3 test_cos_float3(float3 p0) { return cos(p0); }
-// CHECK: define noundef <4 x float> @"?test_cos_float4
+// CHECK: define internal noundef <4 x float> @"?test_cos_float4
 // CHECK: call <4 x float> @llvm.cos.v4f32
 float4 test_cos_float4(float4 p0) { return cos(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/exp.hlsl b/clang/test/CodeGenHLSL/builtins/exp.hlsl
index 773edbe3364fd..2aec84a0ef532 100644
--- a/clang/test/CodeGenHLSL/builtins/exp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %elt.exp = call half @llvm.exp.f16(
 // NATIVE_HALF: ret half %elt.exp
-// NO_HALF: define noundef float @"?test_exp_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_exp_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %elt.exp = call float @llvm.exp.f32(
 // NO_HALF: ret float %elt.exp
 half test_exp_half(half p0) { return exp(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %elt.exp = call <2 x half> @llvm.exp.v2f16
 // NATIVE_HALF: ret <2 x half> %elt.exp
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %elt.exp = call <2 x float> @llvm.exp.v2f32(
 // NO_HALF: ret <2 x float> %elt.exp
 half2 test_exp_half2(half2 p0) { return exp(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %elt.exp = call <3 x half> @llvm.exp.v3f16
 // NATIVE_HALF: ret <3 x half> %elt.exp
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %elt.exp = call <3 x float> @llvm.exp.v3f32(
 // NO_HALF: ret <3 x float> %elt.exp
 half3 test_exp_half3(half3 p0) { return exp(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %elt.exp = call <4 x half> @llvm.exp.v4f16
 // NATIVE_HALF: ret <4 x half> %elt.exp
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %elt.exp = call <4 x float> @llvm.exp.v4f32(
 // NO_HALF: ret <4 x float> %elt.exp
 half4 test_exp_half4(half4 p0) { return exp(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %elt.exp = call float @llvm.exp.f32(
 // CHECK: ret float %elt.exp
 float test_exp_float(float p0) { return exp(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %elt.exp = call <2 x float> @llvm.exp.v2f32
 // CHECK: ret <2 x float> %elt.exp
 float2 test_exp_float2(float2 p0) { return exp(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %elt.exp = call <3 x float> @llvm.exp.v3f32
 // CHECK: ret <3 x float> %elt.exp
 float3 test_exp_float3(float3 p0) { return exp(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %elt.exp = call <4 x float> @llvm.exp.v4f32
 // CHECK: ret <4 x float> %elt.exp
 float4 test_exp_float4(float4 p0) { return exp(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/exp2.hlsl b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
index f21cdd95774ab..92e40e073d501 100644
--- a/clang/test/CodeGenHLSL/builtins/exp2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %elt.exp2 = call half @llvm.exp2.f16(
 // NATIVE_HALF: ret half %elt.exp2
-// NO_HALF: define noundef float @"?test_exp2_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_exp2_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %elt.exp2 = call float @llvm.exp2.f32(
 // NO_HALF: ret float %elt.exp2
 half test_exp2_half(half p0) { return exp2(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %elt.exp2 = call <2 x half> @llvm.exp2.v2f16
 // NATIVE_HALF: ret <2 x half> %elt.exp2
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %elt.exp2 = call <2 x float> @llvm.exp2.v2f32(
 // NO_HALF: ret <2 x float> %elt.exp2
 half2 test_exp2_half2(half2 p0) { return exp2(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %elt.exp2 = call <3 x half> @llvm.exp2.v3f16
 // NATIVE_HALF: ret <3 x half> %elt.exp2
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %elt.exp2 = call <3 x float> @llvm.exp2.v3f32(
 // NO_HALF: ret <3 x float> %elt.exp2
 half3 test_exp2_half3(half3 p0) { return exp2(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %elt.exp2 = call <4 x half> @llvm.exp2.v4f16
 // NATIVE_HALF: ret <4 x half> %elt.exp2
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %elt.exp2 = call <4 x float> @llvm.exp2.v4f32(
 // NO_HALF: ret <4 x float> %elt.exp2
 half4 test_exp2_half4(half4 p0) { return exp2(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %elt.exp2 = call float @llvm.exp2.f32(
 // CHECK: ret float %elt.exp2
 float test_exp2_float(float p0) { return exp2(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %elt.exp2 = call <2 x float> @llvm.exp2.v2f32
 // CHECK: ret <2 x float> %elt.exp2
 float2 test_exp2_float2(float2 p0) { return exp2(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %elt.exp2 = call <3 x float> @llvm.exp2.v3f32
 // CHECK: ret <3 x float> %elt.exp2
 float3 test_exp2_float3(float3 p0) { return exp2(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %elt.exp2 = call <4 x float> @llvm.exp2.v4f32
 // CHECK: ret <4 x float> %elt.exp2
 float4 test_exp2_float4(float4 p0) { return exp2(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/floor.hlsl b/clang/test/CodeGenHLSL/builtins/floor.hlsl
index 48ddf713bcf50..de69a44019572 100644
--- a/clang/test/CodeGenHLSL/builtins/floor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -8,36 +8,36 @@
 
 using hlsl::floor;
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.floor.f16(
-// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.floor.f32(float %0)
 half test_floor_half(half p0) { return floor(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.floor.v2f16(
-// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
 // NO_HALF: call <2 x float> @llvm.floor.v2f32(
 half2 test_floor_half2(half2 p0) { return floor(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.floor.v3f16(
-// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
 // NO_HALF: call <3 x float> @llvm.floor.v3f32(
 half3 test_floor_half3(half3 p0) { return floor(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.floor.v4f16(
-// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define internal noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
 // NO_HALF: call <4 x float> @llvm.floor.v4f32(
 half4 test_floor_half4(half4 p0) { return floor(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: call float @llvm.floor.f32(
 float test_floor_float(float p0) { return floor(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: call <2 x float> @llvm.floor.v2f32(
 float2 test_floor_float2(float2 p0) { return floor(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: call <3 x float> @llvm.floor.v3f32(
 float3 test_floor_float3(float3 p0) { return floor(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: call <4 x float> @llvm.floor.v4f32(
 float4 test_floor_float4(float4 p0) { return floor(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/frac.hlsl b/clang/test/CodeGenHLSL/builtins/frac.hlsl
index 7c4d1468e96d2..556357bba11a9 100644
--- a/clang/test/CodeGenHLSL/builtins/frac.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/frac.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %dx.frac = call half @llvm.dx.frac.f16(
 // NATIVE_HALF: ret half %dx.frac
-// NO_HALF: define noundef float @"?test_frac_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_frac_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %dx.frac = call float @llvm.dx.frac.f32(
 // NO_HALF: ret float %dx.frac
 half test_frac_half(half p0) { return frac(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %dx.frac = call <2 x half> @llvm.dx.frac.v2f16
 // NATIVE_HALF: ret <2 x half> %dx.frac
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %dx.frac = call <2 x float> @llvm.dx.frac.v2f32(
 // NO_HALF: ret <2 x float> %dx.frac
 half2 test_frac_half2(half2 p0) { return frac(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %dx.frac = call <3 x half> @llvm.dx.frac.v3f16
 // NATIVE_HALF: ret <3 x half> %dx.frac
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %dx.frac = call <3 x float> @llvm.dx.frac.v3f32(
 // NO_HALF: ret <3 x float> %dx.frac
 half3 test_frac_half3(half3 p0) { return frac(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %dx.frac = call <4 x half> @llvm.dx.frac.v4f16
 // NATIVE_HALF: ret <4 x half> %dx.frac
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %dx.frac = call <4 x float> @llvm.dx.frac.v4f32(
 // NO_HALF: ret <4 x float> %dx.frac
 half4 test_frac_half4(half4 p0) { return frac(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %dx.frac = call float @llvm.dx.frac.f32(
 // CHECK: ret float %dx.frac
 float test_frac_float(float p0) { return frac(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %dx.frac = call <2 x float> @llvm.dx.frac.v2f32
 // CHECK: ret <2 x float> %dx.frac
 float2 test_frac_float2(float2 p0) { return frac(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %dx.frac = call <3 x float> @llvm.dx.frac.v3f32
 // CHECK: ret <3 x float> %dx.frac
 float3 test_frac_float3(float3 p0) { return frac(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %dx.frac = call <4 x float> @llvm.dx.frac.v4f32
 // CHECK: ret <4 x float> %dx.frac
 float4 test_frac_float4(float4 p0) { return frac(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/isinf.hlsl b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
index df44fc4a91dfd..a8b0d3d03d2de 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
@@ -6,40 +6,40 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// CHECK: define noundef i1 @
+// CHECK: define internal noundef i1 @
 // NATIVE_HALF: %dx.isinf = call i1 @llvm.dx.isinf.f16(
 // NO_HALF: %dx.isinf = call i1 @llvm.dx.isinf.f32(
 // CHECK: ret i1 %dx.isinf
 bool test_isinf_half(half p0) { return isinf(p0); }
-// CHECK: define noundef <2 x i1> @
+// CHECK: define internal noundef <2 x i1> @
 // NATIVE_HALF: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f16
 // NO_HALF: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f32(
 // CHECK: ret <2 x i1> %dx.isinf
 bool2 test_isinf_half2(half2 p0) { return isinf(p0); }
-// NATIVE_HALF: define noundef <3 x i1> @
+// NATIVE_HALF: define internal noundef <3 x i1> @
 // NATIVE_HALF: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f16
 // NO_HALF: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f32(
 // CHECK: ret <3 x i1> %dx.isinf
 bool3 test_isinf_half3(half3 p0) { return isinf(p0); }
-// NATIVE_HALF: define noundef <4 x i1> @
+// NATIVE_HALF: define internal noundef <4 x i1> @
 // NATIVE_HALF: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f16
 // NO_HALF: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32(
 // CHECK: ret <4 x i1> %dx.isinf
 bool4 test_isinf_half4(half4 p0) { return isinf(p0); }
 
-// CHECK: define noundef i1 @
+// CHECK: define internal noundef i1 @
 // CHECK: %dx.isinf = call i1 @llvm.dx.isinf.f32(
 // CHECK: ret i1 %dx.isinf
 bool test_isinf_float(float p0) { return isinf(p0); }
-// CHECK: define noundef <2 x i1> @
+// CHECK: define internal noundef <2 x i1> @
 // CHECK: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f32
 // CHECK: ret <2 x i1> %dx.isinf
 bool2 test_isinf_float2(float2 p0) { return isinf(p0); }
-// CHECK: define noundef <3 x i1> @
+// CHECK: define internal noundef <3 x i1> @
 // CHECK: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f32
 // CHECK: ret <3 x i1> %dx.isinf
 bool3 test_isinf_float3(float3 p0) { return isinf(p0); }
-// CHECK: define noundef <4 x i1> @
+// CHECK: define internal noundef <4 x i1> @
 // CHECK: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32
 // CHECK: ret <4 x i1> %dx.isinf
 bool4 test_isinf_float4(float4 p0) { return isinf(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/log.hlsl b/clang/test/CodeGenHLSL/builtins/log.hlsl
index c89eda683403b..3c30b6b7f4473 100644
--- a/clang/test/CodeGenHLSL/builtins/log.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.log.f16(
-// NO_HALF: define noundef float @"?test_log_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_log_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.log.f32(
 half test_log_half(half p0) { return log(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.log.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_log_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_log_half2
 // NO_HALF: call <2 x float> @llvm.log.v2f32(
 half2 test_log_half2(half2 p0) { return log(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.log.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_log_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_log_half3
 // NO_HALF: call <3 x float> @llvm.log.v3f32(
 half3 test_log_half3(half3 p0) { return log(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.log.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_log_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_log_half4
 // NO_HALF: call <4 x float> @llvm.log.v4f32(
 half4 test_log_half4(half4 p0) { return log(p0); }
 
-// CHECK: define noundef float @"?test_log_float
+// CHECK: define internal noundef float @"?test_log_float
 // CHECK: call float @llvm.log.f32(
 float test_log_float(float p0) { return log(p0); }
-// CHECK: define noundef <2 x float> @"?test_log_float2
+// CHECK: define internal noundef <2 x float> @"?test_log_float2
 // CHECK: call <2 x float> @llvm.log.v2f32
 float2 test_log_float2(float2 p0) { return log(p0); }
-// CHECK: define noundef <3 x float> @"?test_log_float3
+// CHECK: define internal noundef <3 x float> @"?test_log_float3
 // CHECK: call <3 x float> @llvm.log.v3f32
 float3 test_log_float3(float3 p0) { return log(p0); }
-// CHECK: define noundef <4 x float> @"?test_log_float4
+// CHECK: define internal noundef <4 x float> @"?test_log_float4
 // CHECK: call <4 x float> @llvm.log.v4f32
 float4 test_log_float4(float4 p0) { return log(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/log10.hlsl b/clang/test/CodeGenHLSL/builtins/log10.hlsl
index 638b86e8d5eaf..bbc963c729c94 100644
--- a/clang/test/CodeGenHLSL/builtins/log10.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log10.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.log10.f16(
-// NO_HALF: define noundef float @"?test_log10_half
+// NO_HALF: define internal noundef float @"?test_log10_half
 // NO_HALF: call float @llvm.log10.f32(
 half test_log10_half(half p0) { return log10(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.log10.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_log10_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_log10_half2
 // NO_HALF: call <2 x float> @llvm.log10.v2f32(
 half2 test_log10_half2(half2 p0) { return log10(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.log10.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_log10_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_log10_half3
 // NO_HALF: call <3 x float> @llvm.log10.v3f32(
 half3 test_log10_half3(half3 p0) { return log10(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.log10.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_log10_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_log10_half4
 // NO_HALF: call <4 x float> @llvm.log10.v4f32(
 half4 test_log10_half4(half4 p0) { return log10(p0); }
 
-// CHECK: define noundef float @"?test_log10_float
+// CHECK: define internal noundef float @"?test_log10_float
 // CHECK: call float @llvm.log10.f32(
 float test_log10_float(float p0) { return log10(p0); }
-// CHECK: define noundef <2 x float> @"?test_log10_float2
+// CHECK: define internal noundef <2 x float> @"?test_log10_float2
 // CHECK: call <2 x float> @llvm.log10.v2f32
 float2 test_log10_float2(float2 p0) { return log10(p0); }
-// CHECK: define noundef <3 x float> @"?test_log10_float3
+// CHECK: define internal noundef <3 x float> @"?test_log10_float3
 // CHECK: call <3 x float> @llvm.log10.v3f32
 float3 test_log10_float3(float3 p0) { return log10(p0); }
-// CHECK: define noundef <4 x float> @"?test_log10_float4
+// CHECK: define internal noundef <4 x float> @"?test_log10_float4
 // CHECK: call <4 x float> @llvm.log10.v4f32
 float4 test_log10_float4(float4 p0) { return log10(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/log2.hlsl b/clang/test/CodeGenHLSL/builtins/log2.hlsl
index 31c7bff214c61..cf7dc201bf847 100644
--- a/clang/test/CodeGenHLSL/builtins/log2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log2.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.log2.f16(
-// NO_HALF: define noundef float @"?test_log2_half
+// NO_HALF: define internal noundef float @"?test_log2_half
 // NO_HALF: call float @llvm.log2.f32(
 half test_log2_half(half p0) { return log2(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.log2.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_log2_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_log2_half2
 // NO_HALF: call <2 x float> @llvm.log2.v2f32(
 half2 test_log2_half2(half2 p0) { return log2(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.log2.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_log2_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_log2_half3
 // NO_HALF: call <3 x float> @llvm.log2.v3f32(
 half3 test_log2_half3(half3 p0) { return log2(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.log2.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_log2_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_log2_half4
 // NO_HALF: call <4 x float> @llvm.log2.v4f32(
 half4 test_log2_half4(half4 p0) { return log2(p0); }
 
-// CHECK: define noundef float @"?test_log2_float
+// CHECK: define internal noundef float @"?test_log2_float
 // CHECK: call float @llvm.log2.f32(
 float test_log2_float(float p0) { return log2(p0); }
-// CHECK: define noundef <2 x float> @"?test_log2_float2
+// CHECK: define internal noundef <2 x float> @"?test_log2_float2
 // CHECK: call <2 x float> @llvm.log2.v2f32
 float2 test_log2_float2(float2 p0) { return log2(p0); }
-// CHECK: define noundef <3 x float> @"?test_log2_float3
+// CHECK: define internal noundef <3 x float> @"?test_log2_float3
 // CHECK: call <3 x float> @llvm.log2.v3f32
 float3 test_log2_float3(float3 p0) { return log2(p0); }
-// CHECK: define noundef <4 x float> @"?test_log2_float4
+// CHECK: define internal noundef <4 x float> @"?test_log2_float4
 // CHECK: call <4 x float> @llvm.log2.v4f32
 float4 test_log2_float4(float4 p0) { return log2(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/max.hlsl b/clang/test/CodeGenHLSL/builtins/max.hlsl
index f17062f7bb011..dd5325d573a12 100644
--- a/clang/test/CodeGenHLSL/builtins/max.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/max.hlsl
@@ -7,128 +7,128 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
 #ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.smax.i16(
 int16_t test_max_short(int16_t p0, int16_t p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.smax.v2i16(
 int16_t2 test_max_short2(int16_t2 p0, int16_t2 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.smax.v3i16
 int16_t3 test_max_short3(int16_t3 p0, int16_t3 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.smax.v4i16
 int16_t4 test_max_short4(int16_t4 p0, int16_t4 p1) { return max(p0, p1); }
 
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.umax.i16(
 uint16_t test_max_ushort(uint16_t p0, uint16_t p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.umax.v2i16
 uint16_t2 test_max_ushort2(uint16_t2 p0, uint16_t2 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.umax.v3i16
 uint16_t3 test_max_ushort3(uint16_t3 p0, uint16_t3 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.umax.v4i16
 uint16_t4 test_max_ushort4(uint16_t4 p0, uint16_t4 p1) { return max(p0, p1); }
 #endif
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.smax.i32(
 int test_max_int(int p0, int p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.smax.v2i32
 int2 test_max_int2(int2 p0, int2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.smax.v3i32
 int3 test_max_int3(int3 p0, int3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.smax.v4i32
 int4 test_max_int4(int4 p0, int4 p1) { return max(p0, p1); }
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.umax.i32(
 int test_max_uint(uint p0, uint p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.umax.v2i32
 uint2 test_max_uint2(uint2 p0, uint2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.umax.v3i32
 uint3 test_max_uint3(uint3 p0, uint3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.umax.v4i32
 uint4 test_max_uint4(uint4 p0, uint4 p1) { return max(p0, p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.smax.i64(
 int64_t test_max_long(int64_t p0, int64_t p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.smax.v2i64
 int64_t2 test_max_long2(int64_t2 p0, int64_t2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.smax.v3i64
 int64_t3 test_max_long3(int64_t3 p0, int64_t3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.smax.v4i64
 int64_t4 test_max_long4(int64_t4 p0, int64_t4 p1) { return max(p0, p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.umax.i64(
 uint64_t test_max_long(uint64_t p0, uint64_t p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.umax.v2i64
 uint64_t2 test_max_long2(uint64_t2 p0, uint64_t2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.umax.v3i64
 uint64_t3 test_max_long3(uint64_t3 p0, uint64_t3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.umax.v4i64
 uint64_t4 test_max_long4(uint64_t4 p0, uint64_t4 p1) { return max(p0, p1); }
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.maxnum.f16(
-// NO_HALF: define noundef float @"?test_max_half
+// NO_HALF: define internal noundef float @"?test_max_half
 // NO_HALF: call float @llvm.maxnum.f32(
 half test_max_half(half p0, half p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.maxnum.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_max_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_max_half2
 // NO_HALF: call <2 x float> @llvm.maxnum.v2f32(
 half2 test_max_half2(half2 p0, half2 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.maxnum.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_max_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_max_half3
 // NO_HALF: call <3 x float> @llvm.maxnum.v3f32(
 half3 test_max_half3(half3 p0, half3 p1) { return max(p0, p1); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.maxnum.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_max_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_max_half4
 // NO_HALF: call <4 x float> @llvm.maxnum.v4f32(
 half4 test_max_half4(half4 p0, half4 p1) { return max(p0, p1); }
 
-// CHECK: define noundef float @"?test_max_float
+// CHECK: define internal noundef float @"?test_max_float
 // CHECK: call float @llvm.maxnum.f32(
 float test_max_float(float p0, float p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x float> @"?test_max_float2
+// CHECK: define internal noundef <2 x float> @"?test_max_float2
 // CHECK: call <2 x float> @llvm.maxnum.v2f32
 float2 test_max_float2(float2 p0, float2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x float> @"?test_max_float3
+// CHECK: define internal noundef <3 x float> @"?test_max_float3
 // CHECK: call <3 x float> @llvm.maxnum.v3f32
 float3 test_max_float3(float3 p0, float3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x float> @"?test_max_float4
+// CHECK: define internal noundef <4 x float> @"?test_max_float4
 // CHECK: call <4 x float> @llvm.maxnum.v4f32
 float4 test_max_float4(float4 p0, float4 p1) { return max(p0, p1); }
 
-// CHECK: define noundef double @
+// CHECK: define internal noundef double @
 // CHECK: call double @llvm.maxnum.f64(
 double test_max_double(double p0, double p1) { return max(p0, p1); }
-// CHECK: define noundef <2 x double> @
+// CHECK: define internal noundef <2 x double> @
 // CHECK: call <2 x double> @llvm.maxnum.v2f64
 double2 test_max_double2(double2 p0, double2 p1) { return max(p0, p1); }
-// CHECK: define noundef <3 x double> @
+// CHECK: define internal noundef <3 x double> @
 // CHECK: call <3 x double> @llvm.maxnum.v3f64
 double3 test_max_double3(double3 p0, double3 p1) { return max(p0, p1); }
-// CHECK: define noundef <4 x double> @
+// CHECK: define internal noundef <4 x double> @
 // CHECK: call <4 x double> @llvm.maxnum.v4f64
 double4 test_max_double4(double4 p0, double4 p1) { return max(p0, p1); }
diff --git a/clang/test/CodeGenHLSL/builtins/min.hlsl b/clang/test/CodeGenHLSL/builtins/min.hlsl
index a0c233dac4d5f..9cea25c85f084 100644
--- a/clang/test/CodeGenHLSL/builtins/min.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/min.hlsl
@@ -7,128 +7,128 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
 #ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.smin.i16(
 int16_t test_min_short(int16_t p0, int16_t p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.smin.v2i16(
 int16_t2 test_min_short2(int16_t2 p0, int16_t2 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.smin.v3i16
 int16_t3 test_min_short3(int16_t3 p0, int16_t3 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.smin.v4i16
 int16_t4 test_min_short4(int16_t4 p0, int16_t4 p1) { return min(p0, p1); }
 
-// NATIVE_HALF: define noundef i16 @
+// NATIVE_HALF: define internal noundef i16 @
 // NATIVE_HALF: call i16 @llvm.umin.i16(
 uint16_t test_min_ushort(uint16_t p0, uint16_t p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <2 x i16> @
+// NATIVE_HALF: define internal noundef <2 x i16> @
 // NATIVE_HALF: call <2 x i16> @llvm.umin.v2i16
 uint16_t2 test_min_ushort2(uint16_t2 p0, uint16_t2 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <3 x i16> @
+// NATIVE_HALF: define internal noundef <3 x i16> @
 // NATIVE_HALF: call <3 x i16> @llvm.umin.v3i16
 uint16_t3 test_min_ushort3(uint16_t3 p0, uint16_t3 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <4 x i16> @
+// NATIVE_HALF: define internal noundef <4 x i16> @
 // NATIVE_HALF: call <4 x i16> @llvm.umin.v4i16
 uint16_t4 test_min_ushort4(uint16_t4 p0, uint16_t4 p1) { return min(p0, p1); }
 #endif
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.smin.i32(
 int test_min_int(int p0, int p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.smin.v2i32
 int2 test_min_int2(int2 p0, int2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.smin.v3i32
 int3 test_min_int3(int3 p0, int3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.smin.v4i32
 int4 test_min_int4(int4 p0, int4 p1) { return min(p0, p1); }
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.umin.i32(
 int test_min_uint(uint p0, uint p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.umin.v2i32
 uint2 test_min_uint2(uint2 p0, uint2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.umin.v3i32
 uint3 test_min_uint3(uint3 p0, uint3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.umin.v4i32
 uint4 test_min_uint4(uint4 p0, uint4 p1) { return min(p0, p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.smin.i64(
 int64_t test_min_long(int64_t p0, int64_t p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.smin.v2i64
 int64_t2 test_min_long2(int64_t2 p0, int64_t2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.smin.v3i64
 int64_t3 test_min_long3(int64_t3 p0, int64_t3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.smin.v4i64
 int64_t4 test_min_long4(int64_t4 p0, int64_t4 p1) { return min(p0, p1); }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.umin.i64(
 uint64_t test_min_long(uint64_t p0, uint64_t p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.umin.v2i64
 uint64_t2 test_min_long2(uint64_t2 p0, uint64_t2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.umin.v3i64
 uint64_t3 test_min_long3(uint64_t3 p0, uint64_t3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.umin.v4i64
 uint64_t4 test_min_long4(uint64_t4 p0, uint64_t4 p1) { return min(p0, p1); }
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.minnum.f16(
-// NO_HALF: define noundef float @"?test_min_half
+// NO_HALF: define internal noundef float @"?test_min_half
 // NO_HALF: call float @llvm.minnum.f32(
 half test_min_half(half p0, half p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.minnum.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_min_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_min_half2
 // NO_HALF: call <2 x float> @llvm.minnum.v2f32(
 half2 test_min_half2(half2 p0, half2 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.minnum.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_min_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_min_half3
 // NO_HALF: call <3 x float> @llvm.minnum.v3f32(
 half3 test_min_half3(half3 p0, half3 p1) { return min(p0, p1); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.minnum.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_min_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_min_half4
 // NO_HALF: call <4 x float> @llvm.minnum.v4f32(
 half4 test_min_half4(half4 p0, half4 p1) { return min(p0, p1); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: call float @llvm.minnum.f32(
 float test_min_float(float p0, float p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: call <2 x float> @llvm.minnum.v2f32
 float2 test_min_float2(float2 p0, float2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: call <3 x float> @llvm.minnum.v3f32
 float3 test_min_float3(float3 p0, float3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: call <4 x float> @llvm.minnum.v4f32
 float4 test_min_float4(float4 p0, float4 p1) { return min(p0, p1); }
 
-// CHECK: define noundef double @
+// CHECK: define internal noundef double @
 // CHECK: call double @llvm.minnum.f64(
 double test_min_double(double p0, double p1) { return min(p0, p1); }
-// CHECK: define noundef <2 x double> @
+// CHECK: define internal noundef <2 x double> @
 // CHECK: call <2 x double> @llvm.minnum.v2f64
 double2 test_min_double2(double2 p0, double2 p1) { return min(p0, p1); }
-// CHECK: define noundef <3 x double> @
+// CHECK: define internal noundef <3 x double> @
 // CHECK: call <3 x double> @llvm.minnum.v3f64
 double3 test_min_double3(double3 p0, double3 p1) { return min(p0, p1); }
-// CHECK: define noundef <4 x double> @
+// CHECK: define internal noundef <4 x double> @
 // CHECK: call <4 x double> @llvm.minnum.v4f64
 double4 test_min_double4(double4 p0, double4 p1) { return min(p0, p1); }
diff --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl b/clang/test/CodeGenHLSL/builtins/pow.hlsl
index 9a2264e740751..692bf57f5ef59 100644
--- a/clang/test/CodeGenHLSL/builtins/pow.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.pow.f16(
-// NO_HALF: define noundef float @"?test_pow_half
+// NO_HALF: define internal noundef float @"?test_pow_half
 // NO_HALF: call float @llvm.pow.f32(
 half test_pow_half(half p0, half p1) { return pow(p0, p1); }
-// NATIVE_HALF: define noundef <2 x half> @"?test_pow_half2
+// NATIVE_HALF: define internal noundef <2 x half> @"?test_pow_half2
 // NATIVE_HALF: call <2 x half> @llvm.pow.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_pow_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_pow_half2
 // NO_HALF: call <2 x float> @llvm.pow.v2f32(
 half2 test_pow_half2(half2 p0, half2 p1) { return pow(p0, p1); }
-// NATIVE_HALF: define noundef <3 x half> @"?test_pow_half3
+// NATIVE_HALF: define internal noundef <3 x half> @"?test_pow_half3
 // NATIVE_HALF: call <3 x half> @llvm.pow.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_pow_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_pow_half3
 // NO_HALF: call <3 x float> @llvm.pow.v3f32(
 half3 test_pow_half3(half3 p0, half3 p1) { return pow(p0, p1); }
-// NATIVE_HALF: define noundef <4 x half> @"?test_pow_half4
+// NATIVE_HALF: define internal noundef <4 x half> @"?test_pow_half4
 // NATIVE_HALF: call <4 x half> @llvm.pow.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_pow_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_pow_half4
 // NO_HALF: call <4 x float> @llvm.pow.v4f32(
 half4 test_pow_half4(half4 p0, half4 p1) { return pow(p0, p1); }
 
-// CHECK: define noundef float @"?test_pow_float
+// CHECK: define internal noundef float @"?test_pow_float
 // CHECK: call float @llvm.pow.f32(
 float test_pow_float(float p0, float p1) { return pow(p0, p1); }
-// CHECK: define noundef <2 x float> @"?test_pow_float2
+// CHECK: define internal noundef <2 x float> @"?test_pow_float2
 // CHECK: call <2 x float> @llvm.pow.v2f32
 float2 test_pow_float2(float2 p0, float2 p1) { return pow(p0, p1); }
-// CHECK: define noundef <3 x float> @"?test_pow_float3
+// CHECK: define internal noundef <3 x float> @"?test_pow_float3
 // CHECK: call <3 x float> @llvm.pow.v3f32
 float3 test_pow_float3(float3 p0, float3 p1) { return pow(p0, p1); }
-// CHECK: define noundef <4 x float> @"?test_pow_float4
+// CHECK: define internal noundef <4 x float> @"?test_pow_float4
 // CHECK: call <4 x float> @llvm.pow.v4f32
 float4 test_pow_float4(float4 p0, float4 p1) { return pow(p0, p1); }
diff --git a/clang/test/CodeGenHLSL/builtins/rcp.hlsl b/clang/test/CodeGenHLSL/builtins/rcp.hlsl
index eb89bcc4c7c01..9bf479015d2cb 100644
--- a/clang/test/CodeGenHLSL/builtins/rcp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/rcp.hlsl
@@ -13,90 +13,90 @@
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
 
-// DXIL_NATIVE_HALF: define noundef half @
-// SPIR_NATIVE_HALF: define spir_func noundef half @
+// DXIL_NATIVE_HALF: define internal noundef half @
+// SPIR_NATIVE_HALF: define internal spir_func noundef half @
 // NATIVE_HALF: %hlsl.rcp = fdiv half 0xH3C00, %{{.*}} 
 // NATIVE_HALF: ret half %hlsl.rcp
-// DXIL_NO_HALF: define noundef float @
-// SPIR_NO_HALF: define spir_func noundef float @
+// DXIL_NO_HALF: define internal noundef float @
+// SPIR_NO_HALF: define internal spir_func noundef float @
 // NO_HALF: %hlsl.rcp = fdiv float 1.000000e+00, %{{.*}}
 // NO_HALF: ret float %hlsl.rcp
 half test_rcp_half(half p0) { return rcp(p0); }
 
-// DXIL_NATIVE_HALF: define noundef <2 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
+// DXIL_NATIVE_HALF: define internal noundef <2 x half> @
+// SPIR_NATIVE_HALF: define internal spir_func noundef <2 x half> @
 // NATIVE_HALF: %hlsl.rcp = fdiv <2 x half> <half  0xH3C00, half  0xH3C00>, %{{.*}} 
 // NATIVE_HALF: ret <2 x half> %hlsl.rcp
-// DXIL_NO_HALF: define noundef <2 x float> @
-// SPIR_NO_HALF: define spir_func noundef <2 x float> @
+// DXIL_NO_HALF: define internal noundef <2 x float> @
+// SPIR_NO_HALF: define internal spir_func noundef <2 x float> @
 // NO_HALF: %hlsl.rcp = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // NO_HALF: ret <2 x float> %hlsl.rcp
 half2 test_rcp_half2(half2 p0) { return rcp(p0); }
 
-// DXIL_NATIVE_HALF: define noundef <3 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
+// DXIL_NATIVE_HALF: define internal noundef <3 x half> @
+// SPIR_NATIVE_HALF: define internal spir_func noundef <3 x half> @
 // NATIVE_HALF: %hlsl.rcp = fdiv <3 x half> <half  0xH3C00, half  0xH3C00, half  0xH3C00>, %{{.*}} 
 // NATIVE_HALF: ret <3 x half> %hlsl.rcp
-// DXIL_NO_HALF: define noundef <3 x float> @
-// SPIR_NO_HALF: define spir_func noundef <3 x float> @
+// DXIL_NO_HALF: define internal noundef <3 x float> @
+// SPIR_NO_HALF: define internal spir_func noundef <3 x float> @
 // NO_HALF: %hlsl.rcp = fdiv <3 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // NO_HALF: ret <3 x float> %hlsl.rcp
 half3 test_rcp_half3(half3 p0) { return rcp(p0); }
 
-// DXIL_NATIVE_HALF: define noundef <4 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
+// DXIL_NATIVE_HALF: define internal noundef <4 x half> @
+// SPIR_NATIVE_HALF: define internal spir_func noundef <4 x half> @
 // NATIVE_HALF: %hlsl.rcp = fdiv <4 x half> <half  0xH3C00, half  0xH3C00, half  0xH3C00, half  0xH3C00>, %{{.*}} 
 // NATIVE_HALF: ret <4 x half> %hlsl.rcp
-// DXIL_NO_HALF: define noundef <4 x float> @
-// SPIR_NO_HALF: define spir_func noundef <4 x float> @
+// DXIL_NO_HALF: define internal noundef <4 x float> @
+// SPIR_NO_HALF: define internal spir_func noundef <4 x float> @
 // NO_HALF: %hlsl.rcp = fdiv <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // NO_HALF: ret <4 x float> %hlsl.rcp
 half4 test_rcp_half4(half4 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef float @
-// SPIR_CHECK: define spir_func noundef float @
+// DXIL_CHECK: define internal noundef float @
+// SPIR_CHECK: define internal spir_func noundef float @
 // CHECK: %hlsl.rcp = fdiv float 1.000000e+00, %{{.*}}
 // CHECK: ret float %hlsl.rcp
 float test_rcp_float(float p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <2 x float> @
-// SPIR_CHECK: define spir_func noundef <2 x float> @
+// DXIL_CHECK: define internal noundef <2 x float> @
+// SPIR_CHECK: define internal spir_func noundef <2 x float> @
 // CHECK: %hlsl.rcp = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // CHECK: ret <2 x float> %hlsl.rcp
 float2 test_rcp_float2(float2 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <3 x float> @
-// SPIR_CHECK: define spir_func noundef <3 x float> @
+// DXIL_CHECK: define internal noundef <3 x float> @
+// SPIR_CHECK: define internal spir_func noundef <3 x float> @
 // CHECK: %hlsl.rcp = fdiv <3 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // CHECK: ret <3 x float> %hlsl.rcp
 float3 test_rcp_float3(float3 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <4 x float> @
-// SPIR_CHECK: define spir_func noundef <4 x float> @
+// DXIL_CHECK: define internal noundef <4 x float> @
+// SPIR_CHECK: define internal spir_func noundef <4 x float> @
 // CHECK: %hlsl.rcp = fdiv <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %{{.*}}
 // CHECK: ret <4 x float> %hlsl.rcp
 float4 test_rcp_float4(float4 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef double @
-// SPIR_CHECK: define spir_func noundef double @
+// DXIL_CHECK: define internal noundef double @
+// SPIR_CHECK: define internal spir_func noundef double @
 // CHECK: %hlsl.rcp = fdiv double 1.000000e+00, %{{.*}} 
 // CHECK: ret double %hlsl.rcp
 double test_rcp_double(double p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <2 x double> @
-// SPIR_CHECK: define spir_func noundef <2 x double> @
+// DXIL_CHECK: define internal noundef <2 x double> @
+// SPIR_CHECK: define internal spir_func noundef <2 x double> @
 // CHECK: %hlsl.rcp = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %{{.*}}
 // CHECK: ret <2 x double> %hlsl.rcp
 double2 test_rcp_double2(double2 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <3 x double> @
-// SPIR_CHECK: define spir_func noundef <3 x double> @
+// DXIL_CHECK: define internal noundef <3 x double> @
+// SPIR_CHECK: define internal spir_func noundef <3 x double> @
 // CHECK: %hlsl.rcp = fdiv <3 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %{{.*}}
 // CHECK: ret <3 x double> %hlsl.rcp
 double3 test_rcp_double3(double3 p0) { return rcp(p0); }
 
-// DXIL_CHECK: define noundef <4 x double> @
-// SPIR_CHECK: define spir_func noundef <4 x double> @
+// DXIL_CHECK: define internal noundef <4 x double> @
+// SPIR_CHECK: define internal spir_func noundef <4 x double> @
 // CHECK: %hlsl.rcp = fdiv <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %{{.*}}
 // CHECK: ret <4 x double> %hlsl.rcp
 double4 test_rcp_double4(double4 p0) { return rcp(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/reversebits.hlsl b/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
index fe137b9cae4e9..dbfefb065f665 100644
--- a/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
@@ -3,25 +3,25 @@
 // RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
 
 #ifdef __HLSL_ENABLE_16_BIT
-// CHECK: define noundef i16 @
+// CHECK: define internal noundef i16 @
 // CHECK: call i16 @llvm.bitreverse.i16(
 uint16_t test_bitreverse_ushort(uint16_t p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <2 x i16> @
+// CHECK: define internal noundef <2 x i16> @
 // CHECK: call <2 x i16> @llvm.bitreverse.v2i16
 uint16_t2 test_bitreverse_ushort2(uint16_t2 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <3 x i16> @
+// CHECK: define internal noundef <3 x i16> @
 // CHECK: call <3 x i16> @llvm.bitreverse.v3i16
 uint16_t3 test_bitreverse_ushort3(uint16_t3 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <4 x i16> @
+// CHECK: define internal noundef <4 x i16> @
 // CHECK: call <4 x i16> @llvm.bitreverse.v4i16
 uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
 {
@@ -29,50 +29,50 @@ uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
 }
 #endif
 
-// CHECK: define noundef i32 @
+// CHECK: define internal noundef i32 @
 // CHECK: call i32 @llvm.bitreverse.i32(
 int test_bitreverse_uint(uint p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <2 x i32> @
+// CHECK: define internal noundef <2 x i32> @
 // CHECK: call <2 x i32> @llvm.bitreverse.v2i32
 uint2 test_bitreverse_uint2(uint2 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <3 x i32> @
+// CHECK: define internal noundef <3 x i32> @
 // CHECK: call <3 x i32> @llvm.bitreverse.v3i32
 uint3 test_bitreverse_uint3(uint3 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <4 x i32> @
+// CHECK: define internal noundef <4 x i32> @
 // CHECK: call <4 x i32> @llvm.bitreverse.v4i32
 uint4 test_bitreverse_uint4(uint4 p0)
 {
 	return reversebits(p0);
 }
 
-// CHECK: define noundef i64 @
+// CHECK: define internal noundef i64 @
 // CHECK: call i64 @llvm.bitreverse.i64(
 uint64_t test_bitreverse_long(uint64_t p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <2 x i64> @
+// CHECK: define internal noundef <2 x i64> @
 // CHECK: call <2 x i64> @llvm.bitreverse.v2i64
 uint64_t2 test_bitreverse_long2(uint64_t2 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <3 x i64> @
+// CHECK: define internal noundef <3 x i64> @
 // CHECK: call <3 x i64> @llvm.bitreverse.v3i64
 uint64_t3 test_bitreverse_long3(uint64_t3 p0)
 {
 	return reversebits(p0);
 }
-// CHECK: define noundef <4 x i64> @
+// CHECK: define internal noundef <4 x i64> @
 // CHECK: call <4 x i64> @llvm.bitreverse.v4i64
 uint64_t4 test_bitreverse_long4(uint64_t4 p0)
 {
diff --git a/clang/test/CodeGenHLSL/builtins/round.hlsl b/clang/test/CodeGenHLSL/builtins/round.hlsl
index 33d761dbdfbea..692cf9e6f60ef 100644
--- a/clang/test/CodeGenHLSL/builtins/round.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/round.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %elt.roundeven = call half @llvm.roundeven.f16(
 // NATIVE_HALF: ret half %elt.roundeven
-// NO_HALF: define noundef float @"?test_round_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_round_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %elt.roundeven = call float @llvm.roundeven.f32(
 // NO_HALF: ret float %elt.roundeven
 half test_round_half(half p0) { return round(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %elt.roundeven = call <2 x half> @llvm.roundeven.v2f16
 // NATIVE_HALF: ret <2 x half> %elt.roundeven
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %elt.roundeven = call <2 x float> @llvm.roundeven.v2f32(
 // NO_HALF: ret <2 x float> %elt.roundeven
 half2 test_round_half2(half2 p0) { return round(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %elt.roundeven = call <3 x half> @llvm.roundeven.v3f16
 // NATIVE_HALF: ret <3 x half> %elt.roundeven
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %elt.roundeven = call <3 x float> @llvm.roundeven.v3f32(
 // NO_HALF: ret <3 x float> %elt.roundeven
 half3 test_round_half3(half3 p0) { return round(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %elt.roundeven = call <4 x half> @llvm.roundeven.v4f16
 // NATIVE_HALF: ret <4 x half> %elt.roundeven
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %elt.roundeven = call <4 x float> @llvm.roundeven.v4f32(
 // NO_HALF: ret <4 x float> %elt.roundeven
 half4 test_round_half4(half4 p0) { return round(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %elt.roundeven = call float @llvm.roundeven.f32(
 // CHECK: ret float %elt.roundeven
 float test_round_float(float p0) { return round(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %elt.roundeven = call <2 x float> @llvm.roundeven.v2f32
 // CHECK: ret <2 x float> %elt.roundeven
 float2 test_round_float2(float2 p0) { return round(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %elt.roundeven = call <3 x float> @llvm.roundeven.v3f32
 // CHECK: ret <3 x float> %elt.roundeven
 float3 test_round_float3(float3 p0) { return round(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %elt.roundeven = call <4 x float> @llvm.roundeven.v4f32
 // CHECK: ret <4 x float> %elt.roundeven
 float4 test_round_float4(float4 p0) { return round(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
index c87a8c404b08e..0f3e3434891e5 100644
--- a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %dx.rsqrt = call half @llvm.dx.rsqrt.f16(
 // NATIVE_HALF: ret half %dx.rsqrt
-// NO_HALF: define noundef float @"?test_rsqrt_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_rsqrt_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %dx.rsqrt = call float @llvm.dx.rsqrt.f32(
 // NO_HALF: ret float %dx.rsqrt
 half test_rsqrt_half(half p0) { return rsqrt(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %dx.rsqrt = call <2 x half> @llvm.dx.rsqrt.v2f16
 // NATIVE_HALF: ret <2 x half> %dx.rsqrt
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %dx.rsqrt = call <2 x float> @llvm.dx.rsqrt.v2f32(
 // NO_HALF: ret <2 x float> %dx.rsqrt
 half2 test_rsqrt_half2(half2 p0) { return rsqrt(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %dx.rsqrt = call <3 x half> @llvm.dx.rsqrt.v3f16
 // NATIVE_HALF: ret <3 x half> %dx.rsqrt
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %dx.rsqrt = call <3 x float> @llvm.dx.rsqrt.v3f32(
 // NO_HALF: ret <3 x float> %dx.rsqrt
 half3 test_rsqrt_half3(half3 p0) { return rsqrt(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %dx.rsqrt = call <4 x half> @llvm.dx.rsqrt.v4f16
 // NATIVE_HALF: ret <4 x half> %dx.rsqrt
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %dx.rsqrt = call <4 x float> @llvm.dx.rsqrt.v4f32(
 // NO_HALF: ret <4 x float> %dx.rsqrt
 half4 test_rsqrt_half4(half4 p0) { return rsqrt(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %dx.rsqrt = call float @llvm.dx.rsqrt.f32(
 // CHECK: ret float %dx.rsqrt
 float test_rsqrt_float(float p0) { return rsqrt(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %dx.rsqrt = call <2 x float> @llvm.dx.rsqrt.v2f32
 // CHECK: ret <2 x float> %dx.rsqrt
 float2 test_rsqrt_float2(float2 p0) { return rsqrt(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %dx.rsqrt = call <3 x float> @llvm.dx.rsqrt.v3f32
 // CHECK: ret <3 x float> %dx.rsqrt
 float3 test_rsqrt_float3(float3 p0) { return rsqrt(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %dx.rsqrt = call <4 x float> @llvm.dx.rsqrt.v4f32
 // CHECK: ret <4 x float> %dx.rsqrt
 float4 test_rsqrt_float4(float4 p0) { return rsqrt(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/sin.hlsl b/clang/test/CodeGenHLSL/builtins/sin.hlsl
index 83e8a5be39d06..58562fb6de947 100644
--- a/clang/test/CodeGenHLSL/builtins/sin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sin.hlsl
@@ -6,36 +6,36 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: call half @llvm.sin.f16(
-// NO_HALF: define noundef float @"?test_sin_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_sin_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.sin.f32(
 half test_sin_half(half p0) { return sin(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: call <2 x half> @llvm.sin.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_sin_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_sin_half2
 // NO_HALF: call <2 x float> @llvm.sin.v2f32(
 half2 test_sin_half2(half2 p0) { return sin(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: call <3 x half> @llvm.sin.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_sin_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_sin_half3
 // NO_HALF: call <3 x float> @llvm.sin.v3f32(
 half3 test_sin_half3(half3 p0) { return sin(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: call <4 x half> @llvm.sin.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_sin_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_sin_half4
 // NO_HALF: call <4 x float> @llvm.sin.v4f32(
 half4 test_sin_half4(half4 p0) { return sin(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: call float @llvm.sin.f32(
 float test_sin_float(float p0) { return sin(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: call <2 x float> @llvm.sin.v2f32
 float2 test_sin_float2(float2 p0) { return sin(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: call <3 x float> @llvm.sin.v3f32
 float3 test_sin_float3(float3 p0) { return sin(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: call <4 x float> @llvm.sin.v4f32
 float4 test_sin_float4(float4 p0) { return sin(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
index adbbf69a8e068..c64df942ea71a 100644
--- a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
@@ -6,48 +6,48 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: define internal noundef half @
 // NATIVE_HALF: %{{.*}} = call half @llvm.sqrt.f16(
 // NATIVE_HALF: ret half %{{.*}}
-// NO_HALF: define noundef float @"?test_sqrt_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define internal noundef float @"?test_sqrt_half@@YA$halff@$halff@@Z"(
 // NO_HALF: %{{.*}} = call float @llvm.sqrt.f32(
 // NO_HALF: ret float %{{.*}}
 half test_sqrt_half(half p0) { return sqrt(p0); }
-// NATIVE_HALF: define noundef <2 x half> @
+// NATIVE_HALF: define internal noundef <2 x half> @
 // NATIVE_HALF: %{{.*}} = call <2 x half> @llvm.sqrt.v2f16
 // NATIVE_HALF: ret <2 x half> %{{.*}}
-// NO_HALF: define noundef <2 x float> @
+// NO_HALF: define internal noundef <2 x float> @
 // NO_HALF: %{{.*}} = call <2 x float> @llvm.sqrt.v2f32(
 // NO_HALF: ret <2 x float> %{{.*}}
 half2 test_sqrt_half2(half2 p0) { return sqrt(p0); }
-// NATIVE_HALF: define noundef <3 x half> @
+// NATIVE_HALF: define internal noundef <3 x half> @
 // NATIVE_HALF: %{{.*}} = call <3 x half> @llvm.sqrt.v3f16
 // NATIVE_HALF: ret <3 x half> %{{.*}}
-// NO_HALF: define noundef <3 x float> @
+// NO_HALF: define internal noundef <3 x float> @
 // NO_HALF: %{{.*}} = call <3 x float> @llvm.sqrt.v3f32(
 // NO_HALF: ret <3 x float> %{{.*}}
 half3 test_sqrt_half3(half3 p0) { return sqrt(p0); }
-// NATIVE_HALF: define noundef <4 x half> @
+// NATIVE_HALF: define internal noundef <4 x half> @
 // NATIVE_HALF: %{{.*}} = call <4 x half> @llvm.sqrt.v4f16
 // NATIVE_HALF: ret <4 x half> %{{.*}}
-// NO_HALF: define noundef <4 x float> @
+// NO_HALF: define internal noundef <4 x float> @
 // NO_HALF: %{{.*}} = call <4 x float> @llvm.sqrt.v4f32(
 // NO_HALF: ret <4 x float> %{{.*}}
 half4 test_sqrt_half4(half4 p0) { return sqrt(p0); }
 
-// CHECK: define noundef float @
+// CHECK: define internal noundef float @
 // CHECK: %{{.*}} = call float @llvm.sqrt.f32(
 // CHECK: ret float %{{.*}}
 float test_sqrt_float(float p0) { return sqrt(p0); }
-// CHECK: define noundef <2 x float> @
+// CHECK: define internal noundef <2 x float> @
 // CHECK: %{{.*}} = call <2 x float> @llvm.sqrt.v2f32
 // CHECK: ret <2 x float> %{{.*}}
 float2 test_sqrt_float2(float2 p0) { return sqrt(p0); }
-// CHECK: define noundef <3 x float> @
+// CHECK: define internal noundef <3 x float> @
 // CHECK: %{{.*}} = call <3 x float> @llvm.sqrt.v3f32
 // CHECK: ret <3 x float> %{{.*}}
 float3 test_sqrt_float3(float3 p0) { return sqrt(p0); }
-// CHECK: define noundef <4 x float> @
+// CHECK: define internal noundef <4 x float> @
 // CHECK: %{{.*}} = call <4 x float> @llvm.sqrt.v4f32
 // CHECK: ret <4 x float> %{{.*}}
 float4 test_sqrt_float4(float4 p0) { return sqrt(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/trunc.hlsl b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
index 40b71f45a9ccb..7ba855aa706c3 100644
--- a/clang/test/CodeGenHLSL/builtins/trunc.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
@@ -6,42 +6,42 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
-// NATIVE_HALF: define noundef half @"?test_trunc_half
+// NATIVE_HALF: define internal noundef half @"?test_trunc_half
 // NATIVE_HALF: call half @llvm.trunc.f16(
-// NO_HALF: define noundef float @"?test_trunc_half
+// NO_HALF: define internal noundef float @"?test_trunc_half
 // NO_HALF: call float @llvm.trunc.f32(
 half test_trunc_half(half p0) { return trunc(p0); }
 
-// NATIVE_HALF: define noundef <2 x half> @"?test_trunc_half2
+// NATIVE_HALF: define internal noundef <2 x half> @"?test_trunc_half2
 // NATIVE_HALF: call <2 x half> @llvm.trunc.v2f16
-// NO_HALF: define noundef <2 x float> @"?test_trunc_half2
+// NO_HALF: define internal noundef <2 x float> @"?test_trunc_half2
 // NO_HALF: call <2 x float> @llvm.trunc.v2f32(
 half2 test_trunc_half2(half2 p0) { return trunc(p0); }
 
-// NATIVE_HALF: define noundef <3 x half> @"?test_trunc_half3
+// NATIVE_HALF: define internal noundef <3 x half> @"?test_trunc_half3
 // NATIVE_HALF: call <3 x half> @llvm.trunc.v3f16
-// NO_HALF: define noundef <3 x float> @"?test_trunc_half3
+// NO_HALF: define internal noundef <3 x float> @"?test_trunc_half3
 // NO_HALF: call <3 x float> @llvm.trunc.v3f32(
 half3 test_trunc_half3(half3 p0) { return trunc(p0); }
 
-// NATIVE_HALF: define noundef <4 x half> @"?test_trunc_half4
+// NATIVE_HALF: define internal noundef <4 x half> @"?test_trunc_half4
 // NATIVE_HALF: call <4 x half> @llvm.trunc.v4f16
-// NO_HALF: define noundef <4 x float> @"?test_trunc_half4
+// NO_HALF: define internal noundef <4 x float> @"?test_trunc_half4
 // NO_HALF: call <4 x float> @llvm.trunc.v4f32(
 half4 test_trunc_half4(half4 p0) { return trunc(p0); }
 
-// CHECK: define noundef float @"?test_trunc_float
+// CHECK: define internal noundef float @"?test_trunc_float
 // CHECK: call float @llvm.trunc.f32(
 float test_trunc_float(float p0) { return trunc(p0); }
 
-// CHECK: define noundef <2 x float> @"?test_trunc_float2
+// CHECK: define internal noundef <2 x float> @"?test_trunc_float2
 // CHECK: call <2 x float> @llvm.trunc.v2f32
 float2 test_trunc_float2(float2 p0) { return trunc(p0); }
 
-// CHECK: define noundef <3 x float> @"?test_trunc_float3
+// CHECK: define internal noundef <3 x float> @"?test_trunc_float3
 // CHECK: call <3 x float> @llvm.trunc.v3f32
 float3 test_trunc_float3(float3 p0) { return trunc(p0); }
 
-// CHECK: define noundef <4 x float> @"?test_trunc_float4
+// CHECK: define internal noundef <4 x float> @"?test_trunc_float4
 // CHECK: call <4 x float> @llvm.trunc.v4f32
 float4 test_trunc_float4(float4 p0) { return trunc(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
index 9481b0d60a272..799801287166a 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK: define spir_func void @main() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @main() [[A0:#[0-9]+]] {
 void main() {
 // CHECK: entry:
 // CHECK:   %[[CT_ENTRY:[0-9]+]] = call token @llvm.experimental.convergence.entry()
diff --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl
index 8f52d81091c18..effc6d686a5ac 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK: define spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
 // CHECK: %[[CI:[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: call i32 @__hlsl_wave_get_lane_index() [ "convergencectrl"(token %[[CI]]) ]
 uint test_1() {
diff --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl
index 6ea80d692cd24..780250eadd325 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK: define spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
 // CHECK: %[[C1:[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: call i32 @__hlsl_wave_get_lane_index() [ "convergencectrl"(token %[[C1]]) ]
 uint test_1() {
@@ -10,7 +10,7 @@ uint test_1() {
 
 // CHECK-DAG: declare i32 @__hlsl_wave_get_lane_index() [[A1:#[0-9]+]]
 
-// CHECK: define spir_func noundef i32 @_Z6test_2v() [[A0]] {
+// CHECK: define internal spir_func noundef i32 @_Z6test_2v() [[A0]] {
 // CHECK: %[[C2:[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: call spir_func noundef i32 @_Z6test_1v() {{#[0-9]+}} [ "convergencectrl"(token %[[C2]]) ]
 uint test_2() {
diff --git a/clang/test/CodeGenHLSL/convergence/do.while.hlsl b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
index ea5a45ba8fd78..f798ea21ba53e 100644
--- a/clang/test/CodeGenHLSL/convergence/do.while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
@@ -8,7 +8,7 @@ void test1() {
   do {
   } while (cond());
 }
-// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: do.body:
@@ -21,7 +21,7 @@ void test2() {
     foo();
   } while (cond());
 }
-// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: do.body:
@@ -36,7 +36,7 @@ void test3() {
       foo();
   } while (cond());
 }
-// CHECK: define spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: do.body:
@@ -54,7 +54,7 @@ void test4() {
     }
   } while (cond());
 }
-// CHECK: define spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: do.body:
@@ -74,7 +74,7 @@ void test5() {
     }
   } while (cond());
 }
-// CHECK: define spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: do.body:
diff --git a/clang/test/CodeGenHLSL/convergence/for.hlsl b/clang/test/CodeGenHLSL/convergence/for.hlsl
index 180fae74ba751..79d6373cbc7fa 100644
--- a/clang/test/CodeGenHLSL/convergence/for.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/for.hlsl
@@ -10,7 +10,7 @@ void test1() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: for.cond:
@@ -22,7 +22,7 @@ void test2() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: for.cond:
@@ -36,7 +36,7 @@ void test3() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK:                    call spir_func noundef i1 @_Z4condv() [[A3]] [ "convergencectrl"(token [[T0]]) ]
@@ -49,7 +49,7 @@ void test4() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK:                    call spir_func noundef i1 @_Z4condv() [[A3]] [ "convergencectrl"(token [[T0]]) ]
@@ -63,7 +63,7 @@ void test5() {
   for (cond();cond2();foo()) {
   }
 }
-// CHECK: define spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK:                    call spir_func noundef i1 @_Z4condv() [[A3]] [ "convergencectrl"(token [[T0]]) ]
@@ -81,7 +81,7 @@ void test6() {
     }
   }
 }
-// CHECK: define spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK:                    call spir_func noundef i1 @_Z4condv() [[A3]] [ "convergencectrl"(token [[T0]]) ]
@@ -106,7 +106,7 @@ void test7() {
     }
   }
 }
-// CHECK: define spir_func void @_Z5test7v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test7v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK:                    call spir_func noundef i1 @_Z4condv() [[A3]] [ "convergencectrl"(token [[T0]]) ]
diff --git a/clang/test/CodeGenHLSL/convergence/while.hlsl b/clang/test/CodeGenHLSL/convergence/while.hlsl
index 92777000190d2..0c92090eabc75 100644
--- a/clang/test/CodeGenHLSL/convergence/while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/while.hlsl
@@ -8,7 +8,7 @@ void test1() {
   while (cond()) {
   }
 }
-// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
@@ -20,7 +20,7 @@ void test2() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
@@ -36,7 +36,7 @@ void test3() {
     foo();
   }
 }
-// CHECK: define spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
@@ -56,7 +56,7 @@ void test4() {
     }
   }
 }
-// CHECK: define spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
@@ -78,7 +78,7 @@ void test5() {
     }
   }
 }
-// CHECK: define spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
@@ -102,7 +102,7 @@ void test6() {
     }
   }
 }
-// CHECK: define spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
+// CHECK: define internal spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
 // CHECK: entry:
 // CHECK:   [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
 // CHECK: while.cond:
diff --git a/clang/test/CodeGenHLSL/no_int_promotion.hlsl b/clang/test/CodeGenHLSL/no_int_promotion.hlsl
index 78bff3b13810d..3bf4a473e71be 100644
--- a/clang/test/CodeGenHLSL/no_int_promotion.hlsl
+++ b/clang/test/CodeGenHLSL/no_int_promotion.hlsl
@@ -10,37 +10,37 @@
 int16_t add(int16_t a, int16_t b) {
   return a + b;
 }
-// CHECK: define noundef <2 x i16> @
+// CHECK: define internal noundef <2 x i16> @
 // CHECK: add <2 x i16>
 int16_t2 add(int16_t2 a, int16_t2 b) {
   return a + b;
 }
-// CHECK: define noundef <3 x i16> @
+// CHECK: define internal noundef <3 x i16> @
 // CHECK: add <3 x i16>
 int16_t3 add(int16_t3 a, int16_t3 b) {
   return a + b;
 }
-// CHECK: define noundef <4 x i16> @
+// CHECK: define internal noundef <4 x i16> @
 // CHECK: add <4 x i16>
 int16_t4 add(int16_t4 a, int16_t4 b) {
   return a + b;
 }
-// CHECK: define noundef i16 @
+// CHECK: define internal noundef i16 @
 // CHECK: add i16 %
 uint16_t add(uint16_t a, uint16_t b) {
   return a + b;
 }
-// CHECK: define noundef <2 x i16> @
+// CHECK: define internal noundef <2 x i16> @
 // CHECK: add <2 x i16>
 uint16_t2 add(uint16_t2 a, uint16_t2 b) {
   return a + b;
 }
-// CHECK: define noundef <3 x i16> @
+// CHECK: define internal noundef <3 x i16> @
 // CHECK: add <3 x i16>
 uint16_t3 add(uint16_t3 a, uint16_t3 b) {
   return a + b;
 }
-// CHECK: define noundef <4 x i16> @
+// CHECK: define internal noundef <4 x i16> @
 // CHECK: add <4 x i16>
 uint16_t4 add(uint16_t4 a, uint16_t4 b) {
   return a + b;
diff --git a/clang/test/CodeGenHLSL/shift-mask.hlsl b/clang/test/CodeGenHLSL/shift-mask.hlsl
index d046efaf9c1f9..a387ff90f4384 100644
--- a/clang/test/CodeGenHLSL/shift-mask.hlsl
+++ b/clang/test/CodeGenHLSL/shift-mask.hlsl
@@ -6,7 +6,7 @@ int shl32(int V, int S) {
   return V << S;
 }
 
-// CHECK: define noundef i32 @"?shl32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
+// CHECK: define internal noundef i32 @"?shl32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
 // CHECK-DAG:  %[[Masked:.*]] = and i32 %{{.*}}, 31
 // CHECK-DAG:  %{{.*}} = shl i32 %{{.*}}, %[[Masked]]
 
@@ -14,7 +14,7 @@ int shr32(int V, int S) {
   return V >> S;
 }
 
-// CHECK: define noundef i32 @"?shr32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
+// CHECK: define internal noundef i32 @"?shr32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
 // CHECK-DAG:  %[[Masked:.*]] = and i32 %{{.*}}, 31
 // CHECK-DAG:  %{{.*}} = ashr i32 %{{.*}}, %[[Masked]]
 
@@ -22,7 +22,7 @@ int64_t shl64(int64_t V, int64_t S) {
   return V << S;
 }
 
-// CHECK: define noundef i64 @"?shl64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
+// CHECK: define internal noundef i64 @"?shl64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
 // CHECK-DAG:  %[[Masked:.*]] = and i64 %{{.*}}, 63
 // CHECK-DAG:  %{{.*}} = shl i64 %{{.*}}, %[[Masked]]
 
@@ -30,6 +30,6 @@ int64_t shr64(int64_t V, int64_t S) {
   return V >> S;
 }
 
-// CHECK: define noundef i64 @"?shr64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
+// CHECK: define internal noundef i64 @"?shr64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
 // CHECK-DAG:  %[[Masked:.*]] = and i64 %{{.*}}, 63
 // CHECK-DAG:  %{{.*}} = ashr i64 %{{.*}}, %[[Masked]]
diff --git a/clang/test/CodeGenHLSL/this-assignment-overload.hlsl b/clang/test/CodeGenHLSL/this-assignment-overload.hlsl
index d2c630a1fb13d..0cc9afb457b00 100644
--- a/clang/test/CodeGenHLSL/this-assignment-overload.hlsl
+++ b/clang/test/CodeGenHLSL/this-assignment-overload.hlsl
@@ -25,7 +25,7 @@ void main() {
 }
 
 // This test makes a probably safe assumption that HLSL 202x includes operator overloading for assignment operators.
-// CHECK:     define linkonce_odr noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
+// CHECK:     define internal noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
 // CHECK-NEXT:entry:
 // CHECK-NEXT:%this.addr = alloca ptr, align 4
 // CHECK-NEXT:%Another = alloca %struct.Pair, align 4
@@ -42,7 +42,7 @@ void main() {
 // CHECK-NEXT:%0 = load i32, ptr %First2, align 4
 // CHECK-NEXT:ret i32 %0
 
-// CHECK:     define linkonce_odr noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
+// CHECK:     define internal noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
 // CHECK-NEXT:entry:
 // CHECK-NEXT:%this.addr = alloca ptr, align 4
 // CHECK-NEXT:%agg.tmp = alloca %struct.Pair, align 4
diff --git a/clang/test/CodeGenHLSL/this-assignment.hlsl b/clang/test/CodeGenHLSL/this-assignment.hlsl
index 74b4a2eb81500..3815b98e84953 100644
--- a/clang/test/CodeGenHLSL/this-assignment.hlsl
+++ b/clang/test/CodeGenHLSL/this-assignment.hlsl
@@ -24,7 +24,7 @@ void main() {
 }
 
 // This tests reference like implicit this in HLSL
-// CHECK:     define linkonce_odr noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
+// CHECK:     define internal noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
 // CHECK-NEXT:entry:
 // CHECK-NEXT:%this.addr = alloca ptr, align 4
 // CHECK-NEXT:%Another = alloca %struct.Pair, align 4
@@ -34,7 +34,7 @@ void main() {
 // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %this1, ptr align 4 %Another, i32 8, i1 false)
 // CHECK-NEXT:%First = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 0
 
-// CHECK:     define linkonce_odr noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
+// CHECK:     define internal noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
 // CHECK-NEXT:entry:
 // CHECK-NEXT:%this.addr = alloca ptr, align 4
 // CHECK-NEXT:%ref.tmp = alloca %struct.Pair, align 4
diff --git a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
index aeb7a8369f403..356d30a61bba2 100644
--- a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
+++ b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
@@ -4,7 +4,7 @@
 // SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 2018, but HLSL Version is 'hlsl2016'
 
 // valid: "spirv-unknown-vulkan-library"
-// valid: define spir_func void @main() #0 {
+// valid: define internal spir_func void @main() #0 {
 
 [numthreads(1,1,1)]
 void main()

>From a245ec6037734d1b25d4f432da0e379c5c207ca4 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 24 May 2024 13:50:30 -0700
Subject: [PATCH 2/4] clang-format

---
 clang/lib/CodeGen/CGHLSLRuntime.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 0f18c55adaab4..8e5123daf2084 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -354,7 +354,7 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
 }
 
 void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD,
-                                      llvm::Function *Fn) {
+                                       llvm::Function *Fn) {
   if (!FD || !Fn)
     return;
 

>From ca6242ec4087276809b45060234e0804e7de9abc Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Jun 2024 12:08:00 -0700
Subject: [PATCH 3/4] Set internal linkage on groupshared variables; check if
 function is defined

---
 clang/include/clang/Basic/Attr.td   | 4 +++-
 clang/lib/AST/Decl.cpp              | 6 ++++++
 clang/lib/CodeGen/CGHLSLRuntime.cpp | 8 ++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 17d9a710d948b..4e292826d4e1a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -158,8 +158,10 @@ def FunctionTmpl
 
 def HLSLEntry
     : SubsetSubject<Function,
-                    [{S->isExternallyVisible() && !isa<CXXMethodDecl>(S)}],
+                    [{S->getDeclContext()->getRedeclContext()->isFileContext() &&
+                      S->getStorageClass() != SC_Static}],
                     "global functions">;
+                    
 def HLSLBufferObj : SubsetSubject<HLSLBuffer,
                     [{isa<HLSLBufferDecl>(S)}],
                     "cbuffer/tbuffer">;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1f19dadafa44e..dc5566bab312c 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -621,6 +621,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
     // - a variable, variable template, function, or function template
     //   that is explicitly declared static; or
     // (This bullet corresponds to C99 6.2.2p3.)
+    // - also applies to HLSL
     return LinkageInfo::internal();
   }
 
@@ -657,6 +658,11 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
       if (PrevVar->getStorageClass() == SC_Static)
         return LinkageInfo::internal();
     }
+
+    if (Context.getLangOpts().HLSL &&
+        Var->hasAttr<HLSLGroupSharedAddressSpaceAttr>())
+      return LinkageInfo::internal();
+
   } else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
     //   - a data member of an anonymous union.
     const VarDecl *VD = IFD->getVarDecl();
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 8e5123daf2084..173f0c1449c86 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -361,10 +361,10 @@ void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD,
   if (FD->hasAttr<HLSLShaderAttr>()) {
     emitEntryFunction(FD, Fn);
   } else {
-    // HLSL functions that are not shader entry points or exported
-    // have internal linkage by default.
-    // FIXME: skip this for exported functions (Issue #92812)
-    Fn->setLinkage(GlobalValue::InternalLinkage);
+    // HLSL functions defined in the current translation unit that are not
+    // shader entry points or exported have internal linkage by default.
+    if (FD->isDefined())
+      Fn->setLinkage(GlobalValue::InternalLinkage);
   }
 }
 

>From 9555f5a87d8f982d0e25d5c8b601d354a0cd89a9 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Jun 2024 12:09:27 -0700
Subject: [PATCH 4/4] Revert change to isHLSLEntry

---
 clang/include/clang/Basic/Attr.td | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 4e292826d4e1a..c6f08860f203a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -158,10 +158,8 @@ def FunctionTmpl
 
 def HLSLEntry
     : SubsetSubject<Function,
-                    [{S->getDeclContext()->getRedeclContext()->isFileContext() &&
-                      S->getStorageClass() != SC_Static}],
+                    [{S->isExternallyVisible() && !isa<CXXMethodDecl>(S)}],
                     "global functions">;
-                    
 def HLSLBufferObj : SubsetSubject<HLSLBuffer,
                     [{isa<HLSLBufferDecl>(S)}],
                     "cbuffer/tbuffer">;
@@ -4502,7 +4500,6 @@ def HLSLShader : InheritableAttr {
       case HLSLShaderAttr::Mesh:          return llvm::Triple::Mesh;
       case HLSLShaderAttr::Amplification: return llvm::Triple::Amplification;
     }
-    llvm_unreachable("unknown enumeration value");
   }
 }];
 }



More information about the cfe-commits mailing list