[clang] [HLSL] Change default linkage of HLSL functions and groupshared variables (v2) (PR #95331)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 1 10:50:33 PDT 2024
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/95331
>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 01/12] [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 02/12] 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 03/12] 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 04/12] 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");
}
}];
}
>From 79372641e1b39acbf055e41bc590db33035ae5e7 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Jun 2024 14:44:41 -0700
Subject: [PATCH 05/12] Add note to docs about static entry point functions not
being allowed
---
clang/docs/HLSL/ExpectedDifferences.rst | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/clang/docs/HLSL/ExpectedDifferences.rst b/clang/docs/HLSL/ExpectedDifferences.rst
index d1b6010f10f43..24dd209b2d4a9 100644
--- a/clang/docs/HLSL/ExpectedDifferences.rst
+++ b/clang/docs/HLSL/ExpectedDifferences.rst
@@ -108,3 +108,16 @@ behavior between Clang and DXC. Some examples include:
diagnostic notifying the user of the conversion rather than silently altering
precision relative to the other overloads (as FXC does) or generating code
that will fail validation (as DXC does).
+
+Correctness improvements (bug fixes)
+====================================
+
+Entry point functions & ``static`` keyword
+------------------------------------------
+Marking a shader entry point function as ``static`` will result in an error.
+
+This is idential to DXC behavior when an entry point is specified as compiler
+argument. However, DXC does not report an error when compiling a shader library
+that has an entry point function with ``[shader("stage")]`` attribute that is
+also marked ``static``. Additionally, this function definition is not included
+in the final DXIL.
>From 9499de52ffebdf17b70529124c8afae9a0054e41 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Jun 2024 15:21:01 -0700
Subject: [PATCH 06/12] Cleanup
---
clang/docs/HLSL/ExpectedDifferences.rst | 2 +-
clang/include/clang/Basic/Attr.td | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/docs/HLSL/ExpectedDifferences.rst b/clang/docs/HLSL/ExpectedDifferences.rst
index 24dd209b2d4a9..e0de62345bd8c 100644
--- a/clang/docs/HLSL/ExpectedDifferences.rst
+++ b/clang/docs/HLSL/ExpectedDifferences.rst
@@ -114,7 +114,7 @@ Correctness improvements (bug fixes)
Entry point functions & ``static`` keyword
------------------------------------------
-Marking a shader entry point function as ``static`` will result in an error.
+Marking a shader entry point function ``static`` will result in an error.
This is idential to DXC behavior when an entry point is specified as compiler
argument. However, DXC does not report an error when compiling a shader library
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index c6f08860f203a..17d9a710d948b 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4500,6 +4500,7 @@ def HLSLShader : InheritableAttr {
case HLSLShaderAttr::Mesh: return llvm::Triple::Mesh;
case HLSLShaderAttr::Amplification: return llvm::Triple::Amplification;
}
+ llvm_unreachable("unknown enumeration value");
}
}];
}
>From 17e247d76345c848f3e686d5b8aad123d25b7f5b Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Jun 2024 21:47:26 -0700
Subject: [PATCH 07/12] Fix typo
---
clang/docs/HLSL/ExpectedDifferences.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/docs/HLSL/ExpectedDifferences.rst b/clang/docs/HLSL/ExpectedDifferences.rst
index e0de62345bd8c..5654b0428db70 100644
--- a/clang/docs/HLSL/ExpectedDifferences.rst
+++ b/clang/docs/HLSL/ExpectedDifferences.rst
@@ -116,7 +116,7 @@ Entry point functions & ``static`` keyword
------------------------------------------
Marking a shader entry point function ``static`` will result in an error.
-This is idential to DXC behavior when an entry point is specified as compiler
+This is identical to DXC behavior when an entry point is specified as compiler
argument. However, DXC does not report an error when compiling a shader library
that has an entry point function with ``[shader("stage")]`` attribute that is
also marked ``static``. Additionally, this function definition is not included
>From f4fdb0eb680ab1ddf4f289bde30b1a72872b2f8d Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Wed, 12 Jun 2024 16:23:39 -0700
Subject: [PATCH 08/12] [HLSL] (DRAFT) Another way to implement #92071: [HLSL]
Default linkage of HLSL function should be internal
Assigns internal linkage all HLSL functions by default for the Clang semantic analysis phase and then during CodeGen changes it to external linkage for shader entry points, exported functions and function declarations without body.
---
clang/include/clang/Basic/Attr.td | 3 ++-
clang/lib/AST/ASTContext.cpp | 5 +++++
clang/lib/AST/Decl.cpp | 3 +++
clang/lib/CodeGen/CGHLSLRuntime.cpp | 11 +++++++----
clang/lib/Sema/Sema.cpp | 4 ++++
.../SemaHLSL/VectorOverloadResolution.hlsl | 18 +++++++++++++++---
6 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index b70b0c8b836a5..cac4559ce59f7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -158,7 +158,8 @@ 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)}],
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index bf74e56a14799..bbb7468688778 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11974,6 +11974,11 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>())
return true;
+ // HLSL entry functiona are required.
+ if (D->hasAttr<HLSLShaderAttr>())
+ // FIXME: check for HLSL export attribute too
+ return true;
+
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
// Forward declarations aren't required.
if (!FD->doesThisDeclarationHaveABody())
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index dc5566bab312c..a06e7a2d19605 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -687,6 +687,9 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
(!Func || !isFirstInExternCContext(Func)))
return LinkageInfo::internal();
}
+ if (Context.getLangOpts().HLSL) {
+ return LinkageInfo::internal();
+ }
// Set up the defaults.
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 1f49cd00015d5..646d9029e112c 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -361,10 +361,12 @@ void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD,
if (FD->hasAttr<HLSLShaderAttr>()) {
emitEntryFunction(FD, Fn);
} else {
- // 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);
+ // HLSL functions declared in the current translation unit without
+ // body have external linkage by default.
+ if (!FD->isDefined())
+ Fn->setLinkage(GlobalValue::ExternalLinkage);
+
+ // FIXME: also set external linkage on exported functions
}
}
@@ -384,6 +386,7 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
setHLSLEntryAttributes(FD, EntryFn);
// Set the called function as internal linkage.
+ assert(Fn->getLinkage());
Fn->setLinkage(GlobalValue::InternalLinkage);
BasicBlock *BB = BasicBlock::Create(Ctx, "entry", EntryFn);
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a612dcd4b4d03..b3ddb88be4b7d 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -953,6 +953,10 @@ static void checkUndefinedButUsed(Sema &S) {
Func->getIdentifier()->isMangledOpenMPVariantName();
}
}
+ // Do not warn on undefined internal functions in HLSL, they will get
+ // external linkage assigned during CodeGen
+ if (S.getLangOpts().HLSL)
+ continue;
if (!S.getLangOpts().OpenMP || !IsImplicitBase)
S.Diag(VD->getLocation(), diag::warn_undefined_internal)
<< isa<VarDecl>(VD) << VD;
diff --git a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
index 2ea7d14e80eeb..e6850ccfdf45a 100644
--- a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
+++ b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
@@ -39,7 +39,7 @@ void Fn3( int64_t2 p0);
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' <FloatingToIntegral>
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'half2':'half __attribute__((ext_vector_type(2)))' <LValueToRValue>
// CHECK-NEXT: DeclRefExpr {{.*}} 'half2':'half __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'half2':'half __attribute__((ext_vector_type(2)))'
-// CHECKIR-LABEL: Call3
+// CHECKIR-LABEL: define {{.*}}Call3
// CHECKIR: {{.*}} = fptosi <2 x half> {{.*}} to <2 x i64>
void Call3(half2 p0) {
Fn3(p0);
@@ -52,7 +52,7 @@ void Call3(half2 p0) {
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' <FloatingToIntegral>
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' <LValueToRValue>
// CHECK-NEXT: DeclRefExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'float2':'float __attribute__((ext_vector_type(2)))'
-// CHECKIR-LABEL: Call4
+// CHECKIR-LABEL: define {{.*}}Call4
// CHECKIR: {{.*}} = fptosi <2 x float> {{.*}} to <2 x i64>
void Call4(float2 p0) {
Fn3(p0);
@@ -67,8 +67,20 @@ void Fn4( float2 p0);
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' <IntegralToFloating>
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' <LValueToRValue>
// CHECK-NEXT: DeclRefExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'int64_t2':'long __attribute__((ext_vector_type(2)))'
-// CHECKIR-LABEL: Call5
+// CHECKIR-LABEL: define {{.*}}Call5
// CHECKIR: {{.*}} = sitofp <2 x i64> {{.*}} to <2 x float>
void Call5(int64_t2 p0) {
Fn4(p0);
}
+
+// shader entry function using the Call* functions to make sure they are not
+// optimized away and get to codegen to test the IR results
+[shader("compute")]
+[numthreads(4,1,1)]
+void CSMain() {
+ Call(float2(1.0f, -1.0f));
+ Call2(int2(1, -1));
+ Call3(half2(1.0, -1.0));
+ Call4(float2(1.0, -1.0));
+ Call5(int64_t2(1.0, -1.0));
+}
\ No newline at end of file
>From a3a8a9a265099efeae6778020546d39b8acb18c8 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Wed, 26 Jun 2024 12:31:39 -0700
Subject: [PATCH 09/12] [HLSL] Implement `export` keyword
Fixes #92812
(cherry picked from commit b67ecd20cc2c11f4f99c2d90c95fdbd988659947)
---
.../clang/Basic/DiagnosticSemaKinds.td | 3 ++
clang/lib/Parse/ParseDeclCXX.cpp | 8 +++
clang/lib/Parse/Parser.cpp | 2 +-
clang/lib/Sema/SemaModule.cpp | 32 ++++++++++++
clang/test/AST/HLSL/export.hlsl | 23 +++++++++
clang/test/CodeGenHLSL/export.hlsl | 20 ++++++++
clang/test/SemaHLSL/export.hlsl | 50 +++++++++++++++++++
7 files changed, 137 insertions(+), 1 deletion(-)
create mode 100644 clang/test/AST/HLSL/export.hlsl
create mode 100644 clang/test/CodeGenHLSL/export.hlsl
create mode 100644 clang/test/SemaHLSL/export.hlsl
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d3993dda9e316..0f6d7b7ae9163 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12253,6 +12253,9 @@ def warn_hlsl_availability_unavailable :
Warning<err_unavailable.Summary>,
InGroup<HLSLAvailability>, DefaultError;
+def err_hlsl_export_not_on_function : Error<
+ "export declaration can only be used on functions">;
+
// Layout randomization diagnostics.
def err_non_designated_init_used : Error<
"a randomized struct can only be initialized with a designated initializer">;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index d02548f6441f9..9126765f4a65b 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -445,6 +445,14 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, DeclaratorContext Context) {
/// 'export' declaration
/// 'export' '{' declaration-seq[opt] '}'
///
+/// HLSL: Parse export function declaration.
+///
+/// export-function-declaration:
+/// 'export' function-declaration
+///
+/// export-declaration-group:
+/// 'export' '{' function-declaration-seq[opt] '}'
+///
Decl *Parser::ParseExportDeclaration() {
assert(Tok.is(tok::kw_export));
SourceLocation ExportLoc = ConsumeToken();
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 6d0cf7b174e50..ddc8aa9b49e64 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -970,7 +970,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
SingleDecl = ParseModuleImport(SourceLocation(), IS);
} break;
case tok::kw_export:
- if (getLangOpts().CPlusPlusModules) {
+ if (getLangOpts().CPlusPlusModules || getLangOpts().HLSL) {
ProhibitAttributes(Attrs);
SingleDecl = ParseExportDeclaration();
break;
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index ad118ac90e4aa..e920b880ecb4d 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -851,6 +851,21 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
CurContext->addDecl(D);
PushDeclContext(S, D);
+ if (getLangOpts().HLSL) {
+ // exported functions cannot be in an unnamed namespace
+ for (const DeclContext *DC = CurContext; DC; DC = DC->getLexicalParent()) {
+ if (const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
+ if (ND->isAnonymousNamespace()) {
+ Diag(ExportLoc, diag::err_export_within_anonymous_namespace);
+ Diag(ND->getLocation(), diag::note_anonymous_namespace);
+ D->setInvalidDecl();
+ return D;
+ }
+ }
+ }
+ return D;
+ }
+
// C++2a [module.interface]p1:
// An export-declaration shall appear only [...] in the purview of a module
// interface unit. An export-declaration shall not appear directly or
@@ -924,6 +939,23 @@ static bool checkExportedDeclContext(Sema &S, DeclContext *DC,
/// Check that it's valid to export \p D.
static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) {
+ // HLSL: export declaration is valid only on functions
+ if (S.getLangOpts().HLSL) {
+ auto *FD = dyn_cast<FunctionDecl>(D);
+ if (!FD) {
+ if (auto *ED2 = dyn_cast<ExportDecl>(D)) {
+ S.Diag(ED2->getBeginLoc(), diag::err_export_within_export);
+ if (auto *ED1 = dyn_cast<ExportDecl>(D->getDeclContext()))
+ S.Diag(ED1->getBeginLoc(), diag::note_export);
+ }
+ else {
+ S.Diag(D->getBeginLoc(), diag::err_hlsl_export_not_on_function);
+ }
+ D->setInvalidDecl();
+ return false;
+ }
+ }
+
// C++20 [module.interface]p3:
// [...] it shall not declare a name with internal linkage.
bool HasName = false;
diff --git a/clang/test/AST/HLSL/export.hlsl b/clang/test/AST/HLSL/export.hlsl
new file mode 100644
index 0000000000000..69c4fb2b457ac
--- /dev/null
+++ b/clang/test/AST/HLSL/export.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -o - %s | FileCheck %s
+
+// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}> col:1
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:13 used f1 'void ()'
+// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
+export void f1() {}
+
+// CHECK:NamespaceDecl 0x{{[0-9a-f]+}} <{{.*}}>
+// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}> col:3
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:15 used f2 'void ()'
+// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
+namespace MyNamespace {
+ export void f2() {}
+}
+
+// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}>
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:10 used f3 'void ()'
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:10 used f4 'void ()'
+// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
+export {
+ void f3() {}
+ void f4() {}
+}
diff --git a/clang/test/CodeGenHLSL/export.hlsl b/clang/test/CodeGenHLSL/export.hlsl
new file mode 100644
index 0000000000000..cea8875684b9e
--- /dev/null
+++ b/clang/test/CodeGenHLSL/export.hlsl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN: dxil-pc-shadermodel6.3-library %s \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+// CHECK: define void @"?f1@@YAXXZ"()
+export void f1() {
+}
+
+// CHECK: define void @"?f2 at MyNamespace@@YAXXZ"()
+namespace MyNamespace {
+ export void f2() {
+ }
+}
+
+export {
+// CHECK: define void @"?f3@@YAXXZ"()
+// CHECK: define void @"?f4@@YAXXZ"()
+ void f3() {}
+ void f4() {}
+}
\ No newline at end of file
diff --git a/clang/test/SemaHLSL/export.hlsl b/clang/test/SemaHLSL/export.hlsl
new file mode 100644
index 0000000000000..0cb9248f3f589
--- /dev/null
+++ b/clang/test/SemaHLSL/export.hlsl
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - %s -verify
+
+export void f1();
+
+export void f1() {}
+
+namespace { // expected-note {{anonymous namespace begins here}}
+ export void f2(); // expected-error {{export declaration appears within anonymous namespace}}
+}
+
+export void f3();
+
+export { // expected-note {{export block begins here}}
+ void f4() {}
+ export void f5() {} // expected-error {{export declaration appears within another export declaration}}
+ int A; // expected-error {{export declaration can only be used on functions}}
+ namespace ns { // expected-error {{export declaration can only be used on functions}}
+ void f6();
+ }
+}
+
+void export f7() {} // expected-error {{expected unqualified-id}}
+
+export static void f8() {} // expected-error {{declaration of 'f8' with internal linkage cannot be exported}}
+
+export void f9(); // expected-note {{previous declaration is here}}
+static void f9(); // expected-error {{static declaration of 'f9' follows non-static declaration}}
+
+static void f10(); // expected-note {{previous declaration is here}}
+export void f10(); // expected-error {{cannot export redeclaration 'f10' here since the previous declaration has internal linkage}}
+
+export float V1; // expected-error {{export declaration can only be used on functions}}
+
+static export float V2; // expected-error{{expected unqualified-id}}
+
+export static float V3 = 0; // expected-error {{export declaration can only be used on functions}}
+
+export groupshared float V4; // expected-error {{export declaration can only be used on functions}}
+
+void f6() {
+ export int i; // expected-error {{expected expression}}
+}
+
+export cbuffer CB { // expected-error {{export declaration can only be used on functions}}
+ int a;
+}
+
+export template<typename T> void tf1(T t) {} // expected-error {{export declaration can only be used on functions}}
+
+void f5() export {} // expected-error {{expected function body after function declarator}}
\ No newline at end of file
>From 9a2554342e8b43eeed88606022ae46c9a52ea029 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Thu, 27 Jun 2024 13:11:00 -0700
Subject: [PATCH 10/12] Make sure exported and shader entry point functions
have external linkage
One test failing: Clang :: SemaHLSL/entry_shader_redecl.hlsl
Need to figure out the shader entry redeclaration rules.
---
clang/lib/AST/Decl.cpp | 16 +-
clang/lib/CodeGen/CGHLSLRuntime.cpp | 2 +-
clang/test/AST/Interp/hlsl.hlsl | 2 +-
clang/test/CodeGenHLSL/ArrayTemporary.hlsl | 24 +--
.../standard_conversion_sequences.hlsl | 4 +
.../CodeGenHLSL/buffer-array-operator.hlsl | 2 +-
.../CodeGenHLSL/builtins/ScalarSwizzles.hlsl | 4 +
clang/test/CodeGenHLSL/builtins/abs.hlsl | 60 ++++---
clang/test/CodeGenHLSL/builtins/all.hlsl | 164 +++++++++---------
clang/test/CodeGenHLSL/builtins/any.hlsl | 164 +++++++++---------
clang/test/CodeGenHLSL/builtins/ceil.hlsl | 28 +--
.../CodeGenHLSL/builtins/clamp-builtin.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/clamp.hlsl | 84 ++++-----
clang/test/CodeGenHLSL/builtins/cos.hlsl | 28 +--
.../CodeGenHLSL/builtins/create_handle.hlsl | 2 +-
.../CodeGenHLSL/builtins/dot-builtin.hlsl | 6 +-
clang/test/CodeGenHLSL/builtins/dot.hlsl | 4 +
clang/test/CodeGenHLSL/builtins/exp.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/exp2.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/floor.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/frac.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/isinf.hlsl | 20 ++-
.../CodeGenHLSL/builtins/lerp-builtin.hlsl | 4 +-
clang/test/CodeGenHLSL/builtins/lerp.hlsl | 3 +
clang/test/CodeGenHLSL/builtins/log.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/log10.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/log2.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/mad.hlsl | 4 +
clang/test/CodeGenHLSL/builtins/max.hlsl | 84 ++++-----
clang/test/CodeGenHLSL/builtins/min.hlsl | 84 ++++-----
clang/test/CodeGenHLSL/builtins/pow.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/rcp.hlsl | 68 ++++----
.../CodeGenHLSL/builtins/reversebits.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/round.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/rsqrt.hlsl | 52 +++---
clang/test/CodeGenHLSL/builtins/sin.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/sqrt.hlsl | 28 +--
clang/test/CodeGenHLSL/builtins/tan.hlsl | 4 +
clang/test/CodeGenHLSL/builtins/trunc.hlsl | 28 +--
.../wave_get_lane_index_do_while.hlsl | 4 +-
.../builtins/wave_get_lane_index_simple.hlsl | 4 +-
.../builtins/wave_get_lane_index_subcall.hlsl | 8 +-
clang/test/CodeGenHLSL/cbuf.hlsl | 2 +-
clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl | 2 +-
.../CodeGenHLSL/convergence/do.while.hlsl | 14 +-
clang/test/CodeGenHLSL/convergence/for.hlsl | 18 +-
clang/test/CodeGenHLSL/convergence/while.hlsl | 16 +-
.../CodeGenHLSL/convergent-functions.hlsl | 2 +-
clang/test/CodeGenHLSL/float3.hlsl | 2 +-
clang/test/CodeGenHLSL/half.hlsl | 2 +-
clang/test/CodeGenHLSL/no_int_promotion.hlsl | 18 +-
clang/test/CodeGenHLSL/shift-mask.hlsl | 12 +-
.../static_global_and_function_in_cb.hlsl | 2 +-
.../CodeGenHLSL/this-assignment-overload.hlsl | 4 +-
clang/test/CodeGenHLSL/this-assignment.hlsl | 4 +-
.../enable_16bit_types_validation_spirv.hlsl | 1 +
56 files changed, 774 insertions(+), 624 deletions(-)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index a923fec024119..7d89c2dc05f8c 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -668,6 +668,19 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
const VarDecl *VD = IFD->getVarDecl();
assert(VD && "Expected a VarDecl in this IndirectFieldDecl!");
return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
+
+ } else if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
+ // HLSL: functions that are not shader entry points or exported library
+ // functions have internal linkage by default.
+ if (Context.getLangOpts().HLSL &&
+ !(FD->isInExportDeclContext() || FD->hasAttr<HLSLShaderAttr>())) {
+ // Non-library shader entry points might not have an implicit
+ // HLSLShaderAttr added yet so we need to check the entry point name.
+ const TargetInfo &TI = Context.getTargetInfo();
+ if (TI.getTriple().getEnvironment() != llvm::Triple::Library &&
+ FD->getName() != TI.getTargetOpts().HLSLEntry)
+ return LinkageInfo::internal();
+ }
}
assert(!isa<FieldDecl>(D) && "Didn't expect a FieldDecl!");
@@ -687,9 +700,6 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
(!Func || !isFirstInExternCContext(Func)))
return LinkageInfo::internal();
}
- if (Context.getLangOpts().HLSL) {
- return LinkageInfo::internal();
- }
// Set up the defaults.
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 646d9029e112c..cd9dab3aec7ff 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -386,7 +386,7 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
setHLSLEntryAttributes(FD, EntryFn);
// Set the called function as internal linkage.
- assert(Fn->getLinkage());
+ assert(Fn->getLinkage() == GlobalValue::ExternalLinkage);
Fn->setLinkage(GlobalValue::InternalLinkage);
BasicBlock *BB = BasicBlock::Create(Ctx, "entry", EntryFn);
diff --git a/clang/test/AST/Interp/hlsl.hlsl b/clang/test/AST/Interp/hlsl.hlsl
index cb14662c11f39..bdf00c3659bf0 100644
--- a/clang/test/AST/Interp/hlsl.hlsl
+++ b/clang/test/AST/Interp/hlsl.hlsl
@@ -12,7 +12,7 @@
// CHECK: [[splat:%.*]] = insertelement <1 x i32> poison, i32 {{.*}}, i64 0
// CHECK: [[vec2:%.*]] = shufflevector <1 x i32> [[splat]], <1 x i32> poison, <2 x i32> zeroinitializer
// CHECK: ret <2 x i32> [[vec2]]
-int2 ToTwoInts(int V){
+export int2 ToTwoInts(int V){
return V.xx;
}
diff --git a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
index 07076f72405f3..b4ba97eadc993 100644
--- a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
@@ -2,13 +2,13 @@
void fn(float x[2]) { }
-// CHECK-LABEL: define internal void {{.*}}call{{.*}}
+// CHECK-LABEL: define 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)
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[Arr]], i32 8, i1 false)
// CHECK: call void {{.*}}fn{{.*}}(ptr noundef byval([2 x float]) align 4 [[Tmp]])
-void call() {
+export void call() {
float Arr[2] = {0, 0};
fn(Arr);
}
@@ -20,13 +20,13 @@ struct Obj {
void fn2(Obj O[4]) { }
-// CHECK-LABEL: define internal void {{.*}}call2{{.*}}
+// CHECK-LABEL: define 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)
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[Arr]], i32 32, i1 false)
// CHECK: call void {{.*}}fn2{{.*}}(ptr noundef byval([4 x %struct.Obj]) align 4 [[Tmp]])
-void call2() {
+export void call2() {
Obj Arr[4] = {};
fn2(Arr);
}
@@ -34,31 +34,31 @@ void call2() {
void fn3(float x[2][2]) { }
-// CHECK-LABEL: define internal void {{.*}}call3{{.*}}
+// CHECK-LABEL: define 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)
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[Arr]], i32 16, i1 false)
// CHECK: call void {{.*}}fn3{{.*}}(ptr noundef byval([2 x [2 x float]]) align 4 [[Tmp]])
-void call3() {
+export void call3() {
float Arr[2][2] = {{0, 0}, {1,1}};
fn3(Arr);
}
-// CHECK-LABEL: define internal void {{.*}}call4{{.*}}(ptr
+// CHECK-LABEL: define 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)
// CHECK: call void {{.*}}fn3{{.*}}(ptr noundef byval([2 x [2 x float]]) align 4 [[Tmp]])
-void call4(float Arr[2][2]) {
+export void call4(float Arr[2][2]) {
fn3(Arr);
}
// Verify that each template instantiation codegens to a unique and correctly
// mangled function name.
-// CHECK-LABEL: define internal void {{.*}}template_call{{.*}}(ptr
+// CHECK-LABEL: define 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]+]],
@@ -77,7 +77,7 @@ void call4(float Arr[2][2]) {
template<typename T>
void template_fn(T Val) {}
-void template_call(float FA2[2], float FA4[4], int IA3[3]) {
+export void template_call(float FA2[2], float FA4[4], int IA3[3]) {
template_fn(FA2);
template_fn(FA4);
template_fn(IA3);
@@ -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 internal void {{.*}}element_access{{.*}}(ptr
+// CHECK-LABEL: define 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
@@ -98,7 +98,7 @@ void template_call(float FA2[2], float FA4[4], int IA3[3]) {
// CHECK: [[Idx1:%.*]] = getelementptr inbounds [2 x float], ptr [[FA2]], i32 0, i32 1
// CHECK: store float [[Sum]], ptr [[Idx1]]
-void element_access(float FA2[2]) {
+export void element_access(float FA2[2]) {
template_fn(FA2[0]);
FA2[1] = FA2[0] + 5;
}
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
index 06e3cc5af87e1..418ba12ef17d7 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+export {
+
// CHECK-LABEL: f3_to_d4
// CHECK: [[f3:%.*]] = alloca <3 x float>
// CHECK: [[d4:%.*]] = alloca <4 x double>
@@ -117,3 +119,5 @@ void d4_to_b2() {
vector<double,4> d4 = 9.0;
vector<bool, 2> b2 = d4;
}
+
+} //export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/buffer-array-operator.hlsl b/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
index 6bcb06106bf1c..8db7a0d4a31cd 100644
--- a/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
+++ b/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
@@ -3,7 +3,7 @@
const RWBuffer<float> In;
RWBuffer<float> Out;
-void fn(int Idx) {
+export void fn(int Idx) {
Out[Idx] = In[Idx];
}
diff --git a/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl b/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
index 6395ddc2fee2a..1b05c2eba81f7 100644
--- a/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
@@ -2,6 +2,8 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s
+export {
+
// CHECK-LABEL: ToTwoInts
// CHECK: [[splat:%.*]] = insertelement <1 x i32> poison, i32 {{.*}}, i64 0
// CHECK: [[vec2:%.*]] = shufflevector <1 x i32> [[splat]], <1 x i32> poison, <2 x i32> zeroinitializer
@@ -166,3 +168,5 @@ int AssignInt(int V){
X.x = V.x + V.x;
return X;
}
+
+} // export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/abs.hlsl b/clang/test/CodeGenHLSL/builtins/abs.hlsl
index 1a38d9b6f6f7b..632bcf492612f 100644
--- a/clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -8,86 +8,90 @@
using hlsl::abs;
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define internal noundef i16 @
+// NATIVE_HALF: define noundef i16 @
// NATIVE_HALF: call i16 @llvm.abs.i16(
int16_t test_abs_int16_t(int16_t p0) { return abs(p0); }
-// NATIVE_HALF: define internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef half @
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.fabs.f16(
-// NO_HALF: define internal noundef float @"?test_abs_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.fabs.v2f16(
-// NO_HALF: define internal noundef <2 x float> @"?test_abs_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.fabs.v3f16(
-// NO_HALF: define internal noundef <3 x float> @"?test_abs_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.fabs.v4f16(
-// NO_HALF: define internal noundef <4 x float> @"?test_abs_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.abs.i32(
int test_abs_int(int p0) { return abs(p0); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define noundef <2 x i32> @
// CHECK: call <2 x i32> @llvm.abs.v2i32(
int2 test_abs_int2(int2 p0) { return abs(p0); }
-// CHECK: define internal noundef <3 x i32> @
+// CHECK: define noundef <3 x i32> @
// CHECK: call <3 x i32> @llvm.abs.v3i32(
int3 test_abs_int3(int3 p0) { return abs(p0); }
-// CHECK: define internal noundef <4 x i32> @
+// CHECK: define noundef <4 x i32> @
// CHECK: call <4 x i32> @llvm.abs.v4i32(
int4 test_abs_int4(int4 p0) { return abs(p0); }
-// CHECK: define internal noundef float @
+// CHECK: define noundef float @
// CHECK: call float @llvm.fabs.f32(
float test_abs_float(float p0) { return abs(p0); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define noundef <2 x float> @
// CHECK: call <2 x float> @llvm.fabs.v2f32(
float2 test_abs_float2(float2 p0) { return abs(p0); }
-// CHECK: define internal noundef <3 x float> @
+// CHECK: define noundef <3 x float> @
// CHECK: call <3 x float> @llvm.fabs.v3f32(
float3 test_abs_float3(float3 p0) { return abs(p0); }
-// CHECK: define internal noundef <4 x float> @
+// CHECK: define noundef <4 x float> @
// CHECK: call <4 x float> @llvm.fabs.v4f32(
float4 test_abs_float4(float4 p0) { return abs(p0); }
-// CHECK: define internal noundef i64 @
+// CHECK: define noundef i64 @
// CHECK: call i64 @llvm.abs.i64(
int64_t test_abs_int64_t(int64_t p0) { return abs(p0); }
-// CHECK: define internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef double @
+// CHECK: define noundef double @
// CHECK: call double @llvm.fabs.f64(
double test_abs_double(double p0) { return abs(p0); }
-// CHECK: define internal noundef <2 x double> @
+// CHECK: define noundef <2 x double> @
// CHECK: call <2 x double> @llvm.fabs.v2f64(
double2 test_abs_double2(double2 p0) { return abs(p0); }
-// CHECK: define internal noundef <3 x double> @
+// CHECK: define noundef <3 x double> @
// CHECK: call <3 x double> @llvm.fabs.v3f64(
double3 test_abs_double3(double3 p0) { return abs(p0); }
-// CHECK: define internal noundef <4 x double> @
+// CHECK: define noundef <4 x double> @
// CHECK: call <4 x double> @llvm.fabs.v4f64(
double4 test_abs_double4(double4 p0) { return abs(p0); }
+
+} // export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl b/clang/test/CodeGenHLSL/builtins/all.hlsl
index 8437199a7da52..1ef0c12376826 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -13,60 +13,62 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +76,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +85,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +94,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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,177 +103,179 @@ 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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
bool test_all_bool4(bool4 p0) { return all(p0); }
+
+} // export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/any.hlsl b/clang/test/CodeGenHLSL/builtins/any.hlsl
index b4962ab30becc..458cbca9109b3 100644
--- a/clang/test/CodeGenHLSL/builtins/any.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/any.hlsl
@@ -13,66 +13,68 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_NATIVE_HALF: define internal spir_func noundef i1 @
+// DXIL_NATIVE_HALF: define noundef i1 @
+// SPIR_NATIVE_HALF: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +82,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +91,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 +100,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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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,198 +109,200 @@ 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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 internal noundef i1 @
-// SPIR_CHECK: define internal spir_func noundef i1 @
+// DXIL_CHECK: define noundef i1 @
+// SPIR_CHECK: define 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
bool test_any_bool4(bool4 p0) { return any(p0); }
+
+} // export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/ceil.hlsl b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
index ee6ecdc77f386..49948306fc330 100644
--- a/clang/test/CodeGenHLSL/builtins/ceil.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
@@ -8,36 +8,40 @@
using hlsl::ceil;
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.ceil.f16(
-// NO_HALF: define internal noundef float @"?test_ceil_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.ceil.v2f16(
-// NO_HALF: define internal noundef <2 x float> @"?test_ceil_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.ceil.v3f16(
-// NO_HALF: define internal noundef <3 x float> @"?test_ceil_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.ceil.v4f16(
-// NO_HALF: define internal noundef <4 x float> @"?test_ceil_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define noundef float @
// CHECK: call float @llvm.ceil.f32(
float test_ceil_float(float p0) { return ceil(p0); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define noundef <2 x float> @
// CHECK: call <2 x float> @llvm.ceil.v2f32(
float2 test_ceil_float2(float2 p0) { return ceil(p0); }
-// CHECK: define internal noundef <3 x float> @
+// CHECK: define noundef <3 x float> @
// CHECK: call <3 x float> @llvm.ceil.v3f32(
float3 test_ceil_float3(float3 p0) { return ceil(p0); }
-// CHECK: define internal noundef <4 x float> @
+// CHECK: define noundef <4 x float> @
// CHECK: call <4 x float> @llvm.ceil.v4f32(
float4 test_ceil_float4(float4 p0) { return ceil(p0); }
+
+} // export
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl
index e3ef26429e7e4..0be010aacada8 100644
--- a/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl
@@ -3,6 +3,6 @@
// CHECK-LABEL: builtin_test_clamp_int4
// CHECK: %dx.clamp = call <4 x i32> @llvm.dx.clamp.v4i32(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2)
// CHECK: ret <4 x i32> %dx.clamp
-int4 builtin_test_clamp_int4(int4 p0, int4 p1, int4 p2) {
+export int4 builtin_test_clamp_int4(int4 p0, int4 p1, int4 p2) {
return __builtin_hlsl_elementwise_clamp(p0, p1, p2);
}
diff --git a/clang/test/CodeGenHLSL/builtins/clamp.hlsl b/clang/test/CodeGenHLSL/builtins/clamp.hlsl
index 521b89b82f07c..9fcb0d0f7a91e 100644
--- a/clang/test/CodeGenHLSL/builtins/clamp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/clamp.hlsl
@@ -6,129 +6,133 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.dx.clamp.i32(
int test_clamp_int(int p0, int p1) { return clamp(p0, p1,p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.dx.uclamp.i32(
int test_clamp_uint(uint p0, uint p1) { return clamp(p0, p1,p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef half @
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.dx.clamp.f16(
-// NO_HALF: define internal noundef float @"?test_clamp_half
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.dx.clamp.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_clamp_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.dx.clamp.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_clamp_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.dx.clamp.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_clamp_half4
+// NO_HALF: define 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 internal noundef float @"?test_clamp_float
+// CHECK: define 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 internal noundef <2 x float> @"?test_clamp_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_clamp_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_clamp_float4
+// CHECK: define 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 internal noundef double @
+// CHECK: define noundef double @
// CHECK: call double @llvm.dx.clamp.f64(
double test_clamp_double(double p0, double p1) { return clamp(p0, p1,p1); }
-// CHECK: define internal noundef <2 x double> @
+// CHECK: define 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 internal noundef <3 x double> @
+// CHECK: define 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 internal noundef <4 x double> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/cos.hlsl b/clang/test/CodeGenHLSL/builtins/cos.hlsl
index 84b722c421f64..914f48ab3e460 100644
--- a/clang/test/CodeGenHLSL/builtins/cos.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/cos.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.cos.f16(
-// NO_HALF: define internal noundef float @"?test_cos_half
+// NO_HALF: define noundef float @"?test_cos_half
// NO_HALF: call float @llvm.cos.f32(
half test_cos_half(half p0) { return cos(p0); }
-// NATIVE_HALF: define internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.cos.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_cos_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.cos.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_cos_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.cos.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_cos_half4
+// NO_HALF: define 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 internal noundef float @"?test_cos_float
+// CHECK: define noundef float @"?test_cos_float
// CHECK: call float @llvm.cos.f32(
float test_cos_float(float p0) { return cos(p0); }
-// CHECK: define internal noundef <2 x float> @"?test_cos_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_cos_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_cos_float4
+// CHECK: define noundef <4 x float> @"?test_cos_float4
// CHECK: call <4 x float> @llvm.cos.v4f32
float4 test_cos_float4(float4 p0) { return cos(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/create_handle.hlsl b/clang/test/CodeGenHLSL/builtins/create_handle.hlsl
index 61226c2b54e72..39f6341c3d328 100644
--- a/clang/test/CodeGenHLSL/builtins/create_handle.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/create_handle.hlsl
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
-void fn() {
+export void fn() {
(void)__builtin_hlsl_create_handle(0);
}
diff --git a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
index 9881dabc3a110..09ffa5f694b86 100644
--- a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
@@ -5,7 +5,7 @@
// CHECK: %dx.dot = fmul double %conv, %conv1
// CHECK: %conv2 = fptrunc double %dx.dot to float
// CHECK: ret float %conv2
-float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) {
+export float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) {
return __builtin_hlsl_dot ( p0, p1 );
}
@@ -15,7 +15,7 @@ float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) {
// CHECK: %dx.dot = fmul double %conv, %conv1
// CHECK: %conv2 = fptrunc double %dx.dot to float
// CHECK: ret float %conv2
-float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) {
+export float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) {
return __builtin_hlsl_dot ( p0, p1 );
}
@@ -25,6 +25,6 @@ float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) {
// CHECK: dx.dot = fmul double %conv, %conv1
// CHECK: %conv2 = fptrunc double %dx.dot to float
// CHECK: ret float %conv2
-float builtin_dot_int_to_float_promotion ( float p0, int p1 ) {
+export float builtin_dot_int_to_float_promotion ( float p0, int p1 ) {
return __builtin_hlsl_dot ( p0, p1 );
}
diff --git a/clang/test/CodeGenHLSL/builtins/dot.hlsl b/clang/test/CodeGenHLSL/builtins/dot.hlsl
index 307d71cce3cb6..4c35ba7f42515 100644
--- a/clang/test/CodeGenHLSL/builtins/dot.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dot.hlsl
@@ -6,6 +6,8 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
// NATIVE_HALF: %dx.dot = mul i16 %0, %1
// NATIVE_HALF: ret i16 %dx.dot
@@ -191,3 +193,5 @@ int test_dot_bool_scalar_arg0_type_promotion(bool p0, int p1) {
int test_dot_bool_scalar_arg1_type_promotion(int p0, bool p1) {
return dot(p0, p1);
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/exp.hlsl b/clang/test/CodeGenHLSL/builtins/exp.hlsl
index 2aec84a0ef532..c92cec2735071 100644
--- a/clang/test/CodeGenHLSL/builtins/exp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp.hlsl
@@ -6,48 +6,52 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: %elt.exp = call half @llvm.exp.f16(
// NATIVE_HALF: ret half %elt.exp
-// NO_HALF: define internal noundef float @"?test_exp_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define 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 internal noundef <2 x float> @
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define 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 internal noundef <3 x float> @
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define 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 internal noundef <4 x float> @
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define 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 internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/exp2.hlsl b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
index 92e40e073d501..d538fa0475269 100644
--- a/clang/test/CodeGenHLSL/builtins/exp2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
@@ -6,48 +6,52 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: %elt.exp2 = call half @llvm.exp2.f16(
// NATIVE_HALF: ret half %elt.exp2
-// NO_HALF: define internal noundef float @"?test_exp2_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define 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 internal noundef <2 x float> @
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define 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 internal noundef <3 x float> @
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define 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 internal noundef <4 x float> @
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define 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 internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/floor.hlsl b/clang/test/CodeGenHLSL/builtins/floor.hlsl
index de69a44019572..53a910093e0a3 100644
--- a/clang/test/CodeGenHLSL/builtins/floor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -8,36 +8,40 @@
using hlsl::floor;
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.floor.f16(
-// NO_HALF: define internal noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.floor.v2f16(
-// NO_HALF: define internal noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.floor.v3f16(
-// NO_HALF: define internal noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.floor.v4f16(
-// NO_HALF: define internal noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03 at __clang@@T12@@Z"(
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define noundef float @
// CHECK: call float @llvm.floor.f32(
float test_floor_float(float p0) { return floor(p0); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define noundef <2 x float> @
// CHECK: call <2 x float> @llvm.floor.v2f32(
float2 test_floor_float2(float2 p0) { return floor(p0); }
-// CHECK: define internal noundef <3 x float> @
+// CHECK: define noundef <3 x float> @
// CHECK: call <3 x float> @llvm.floor.v3f32(
float3 test_floor_float3(float3 p0) { return floor(p0); }
-// CHECK: define internal noundef <4 x float> @
+// CHECK: define noundef <4 x float> @
// CHECK: call <4 x float> @llvm.floor.v4f32(
float4 test_floor_float4(float4 p0) { return floor(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/frac.hlsl b/clang/test/CodeGenHLSL/builtins/frac.hlsl
index 556357bba11a9..b47ece62b6bcf 100644
--- a/clang/test/CodeGenHLSL/builtins/frac.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/frac.hlsl
@@ -6,48 +6,52 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: %dx.frac = call half @llvm.dx.frac.f16(
// NATIVE_HALF: ret half %dx.frac
-// NO_HALF: define internal noundef float @"?test_frac_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define 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 internal noundef <2 x float> @
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define 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 internal noundef <3 x float> @
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define 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 internal noundef <4 x float> @
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define 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 internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/isinf.hlsl b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
index a8b0d3d03d2de..d10c4ea1d44dd 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
@@ -6,40 +6,44 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// CHECK: define internal noundef i1 @
+export {
+
+// CHECK: define 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 internal noundef <2 x i1> @
+// CHECK: define 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 internal noundef <3 x i1> @
+// NATIVE_HALF: define 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 internal noundef <4 x i1> @
+// NATIVE_HALF: define 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 internal noundef i1 @
+// CHECK: define 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 internal noundef <2 x i1> @
+// CHECK: define 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 internal noundef <3 x i1> @
+// CHECK: define 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 internal noundef <4 x i1> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl
index f9b3cbcddfb69..7da3ea2b102c3 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl
@@ -3,13 +3,13 @@
// CHECK-LABEL: builtin_lerp_half_vector
// CHECK: %hlsl.lerp = call <3 x half> @llvm.dx.lerp.v3f16(<3 x half> %0, <3 x half> %1, <3 x half> %2)
// CHECK: ret <3 x half> %hlsl.lerp
-half3 builtin_lerp_half_vector (half3 p0) {
+export half3 builtin_lerp_half_vector (half3 p0) {
return __builtin_hlsl_lerp ( p0, p0, p0 );
}
// CHECK-LABEL: builtin_lerp_floar_vector
// CHECK: %hlsl.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 x float> %1, <2 x float> %2)
// CHECK: ret <2 x float> %hlsl.lerp
-float2 builtin_lerp_floar_vector ( float2 p0) {
+export float2 builtin_lerp_floar_vector ( float2 p0) {
return __builtin_hlsl_lerp ( p0, p0, p0 );
}
diff --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index bbb419acaf3ba..6979ea6768cfb 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -13,6 +13,7 @@
// 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
+export {
// DXIL_NATIVE_HALF: %hlsl.lerp = call half @llvm.dx.lerp.f16(half %{{.*}}, half %{{.*}}, half %{{.*}})
// SPIR_NATIVE_HALF: %hlsl.lerp = call half @llvm.spv.lerp.f16(half %{{.*}}, half %{{.*}}, half %{{.*}})
@@ -110,3 +111,5 @@ float2 test_lerp_float2_int_splat(float2 p0, int p1) {
float3 test_lerp_float3_int_splat(float3 p0, int p1) {
return lerp(p0, p0, p1);
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/log.hlsl b/clang/test/CodeGenHLSL/builtins/log.hlsl
index 3c30b6b7f4473..2051d220436e1 100644
--- a/clang/test/CodeGenHLSL/builtins/log.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.log.f16(
-// NO_HALF: define internal noundef float @"?test_log_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.log.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_log_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.log.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_log_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.log.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_log_half4
+// NO_HALF: define 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 internal noundef float @"?test_log_float
+// CHECK: define noundef float @"?test_log_float
// CHECK: call float @llvm.log.f32(
float test_log_float(float p0) { return log(p0); }
-// CHECK: define internal noundef <2 x float> @"?test_log_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_log_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_log_float4
+// CHECK: define noundef <4 x float> @"?test_log_float4
// CHECK: call <4 x float> @llvm.log.v4f32
float4 test_log_float4(float4 p0) { return log(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/log10.hlsl b/clang/test/CodeGenHLSL/builtins/log10.hlsl
index bbc963c729c94..1fa0c7a589d6f 100644
--- a/clang/test/CodeGenHLSL/builtins/log10.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log10.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.log10.f16(
-// NO_HALF: define internal noundef float @"?test_log10_half
+// NO_HALF: define noundef float @"?test_log10_half
// NO_HALF: call float @llvm.log10.f32(
half test_log10_half(half p0) { return log10(p0); }
-// NATIVE_HALF: define internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.log10.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_log10_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.log10.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_log10_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.log10.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_log10_half4
+// NO_HALF: define 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 internal noundef float @"?test_log10_float
+// CHECK: define noundef float @"?test_log10_float
// CHECK: call float @llvm.log10.f32(
float test_log10_float(float p0) { return log10(p0); }
-// CHECK: define internal noundef <2 x float> @"?test_log10_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_log10_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_log10_float4
+// CHECK: define noundef <4 x float> @"?test_log10_float4
// CHECK: call <4 x float> @llvm.log10.v4f32
float4 test_log10_float4(float4 p0) { return log10(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/log2.hlsl b/clang/test/CodeGenHLSL/builtins/log2.hlsl
index cf7dc201bf847..eafdcc070966b 100644
--- a/clang/test/CodeGenHLSL/builtins/log2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log2.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.log2.f16(
-// NO_HALF: define internal noundef float @"?test_log2_half
+// NO_HALF: define noundef float @"?test_log2_half
// NO_HALF: call float @llvm.log2.f32(
half test_log2_half(half p0) { return log2(p0); }
-// NATIVE_HALF: define internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.log2.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_log2_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.log2.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_log2_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.log2.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_log2_half4
+// NO_HALF: define 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 internal noundef float @"?test_log2_float
+// CHECK: define noundef float @"?test_log2_float
// CHECK: call float @llvm.log2.f32(
float test_log2_float(float p0) { return log2(p0); }
-// CHECK: define internal noundef <2 x float> @"?test_log2_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_log2_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_log2_float4
+// CHECK: define noundef <4 x float> @"?test_log2_float4
// CHECK: call <4 x float> @llvm.log2.v4f32
float4 test_log2_float4(float4 p0) { return log2(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/mad.hlsl b/clang/test/CodeGenHLSL/builtins/mad.hlsl
index 559e1d1dd3903..cf29fe0d9b31b 100644
--- a/clang/test/CodeGenHLSL/builtins/mad.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/mad.hlsl
@@ -14,6 +14,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_CHECK
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
// DXIL_NATIVE_HALF: %dx.umad = call i16 @llvm.dx.umad.i16(i16 %0, i16 %1, i16 %2)
// DXIL_NATIVE_HALF: ret i16 %dx.umad
@@ -303,3 +305,5 @@ float2 test_mad_float2_int_splat(float2 p0, float2 p1, int p2) {
float3 test_mad_float3_int_splat(float3 p0, float3 p1, int p2) {
return mad(p0, p1, p2);
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/max.hlsl b/clang/test/CodeGenHLSL/builtins/max.hlsl
index dd5325d573a12..59d0c518b11f0 100644
--- a/clang/test/CodeGenHLSL/builtins/max.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/max.hlsl
@@ -6,129 +6,133 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.smax.i32(
int test_max_int(int p0, int p1) { return max(p0, p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.umax.i32(
int test_max_uint(uint p0, uint p1) { return max(p0, p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef half @
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.maxnum.f16(
-// NO_HALF: define internal noundef float @"?test_max_half
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.maxnum.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_max_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.maxnum.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_max_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.maxnum.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_max_half4
+// NO_HALF: define 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 internal noundef float @"?test_max_float
+// CHECK: define 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 internal noundef <2 x float> @"?test_max_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_max_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_max_float4
+// CHECK: define 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 internal noundef double @
+// CHECK: define noundef double @
// CHECK: call double @llvm.maxnum.f64(
double test_max_double(double p0, double p1) { return max(p0, p1); }
-// CHECK: define internal noundef <2 x double> @
+// CHECK: define 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 internal noundef <3 x double> @
+// CHECK: define 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 internal noundef <4 x double> @
+// CHECK: define noundef <4 x double> @
// CHECK: call <4 x double> @llvm.maxnum.v4f64
double4 test_max_double4(double4 p0, double4 p1) { return max(p0, p1); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/min.hlsl b/clang/test/CodeGenHLSL/builtins/min.hlsl
index 9cea25c85f084..eea2c6917c630 100644
--- a/clang/test/CodeGenHLSL/builtins/min.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/min.hlsl
@@ -6,129 +6,133 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: define internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i16 @
+// NATIVE_HALF: define 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 internal noundef <2 x i16> @
+// NATIVE_HALF: define 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 internal noundef <3 x i16> @
+// NATIVE_HALF: define 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 internal noundef <4 x i16> @
+// NATIVE_HALF: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.smin.i32(
int test_min_int(int p0, int p1) { return min(p0, p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.umin.i32(
int test_min_uint(uint p0, uint p1) { return min(p0, p1); }
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define 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 internal noundef <3 x i32> @
+// CHECK: define 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 internal noundef <4 x i32> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef i64 @
+// CHECK: define 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 internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define 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 internal noundef half @
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.minnum.f16(
-// NO_HALF: define internal noundef float @"?test_min_half
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.minnum.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_min_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.minnum.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_min_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.minnum.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_min_half4
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define noundef float @
// CHECK: call float @llvm.minnum.f32(
float test_min_float(float p0, float p1) { return min(p0, p1); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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 internal noundef double @
+// CHECK: define noundef double @
// CHECK: call double @llvm.minnum.f64(
double test_min_double(double p0, double p1) { return min(p0, p1); }
-// CHECK: define internal noundef <2 x double> @
+// CHECK: define 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 internal noundef <3 x double> @
+// CHECK: define 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 internal noundef <4 x double> @
+// CHECK: define noundef <4 x double> @
// CHECK: call <4 x double> @llvm.minnum.v4f64
double4 test_min_double4(double4 p0, double4 p1) { return min(p0, p1); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl b/clang/test/CodeGenHLSL/builtins/pow.hlsl
index 692bf57f5ef59..3804ba3d4ff49 100644
--- a/clang/test/CodeGenHLSL/builtins/pow.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.pow.f16(
-// NO_HALF: define internal noundef float @"?test_pow_half
+// NO_HALF: define 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 internal noundef <2 x half> @"?test_pow_half2
+// NATIVE_HALF: define noundef <2 x half> @"?test_pow_half2
// NATIVE_HALF: call <2 x half> @llvm.pow.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_pow_half2
+// NO_HALF: define 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 internal noundef <3 x half> @"?test_pow_half3
+// NATIVE_HALF: define noundef <3 x half> @"?test_pow_half3
// NATIVE_HALF: call <3 x half> @llvm.pow.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_pow_half3
+// NO_HALF: define 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 internal noundef <4 x half> @"?test_pow_half4
+// NATIVE_HALF: define noundef <4 x half> @"?test_pow_half4
// NATIVE_HALF: call <4 x half> @llvm.pow.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_pow_half4
+// NO_HALF: define 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 internal noundef float @"?test_pow_float
+// CHECK: define 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 internal noundef <2 x float> @"?test_pow_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_pow_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_pow_float4
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/rcp.hlsl b/clang/test/CodeGenHLSL/builtins/rcp.hlsl
index 9bf479015d2cb..3595ff55eb9b6 100644
--- a/clang/test/CodeGenHLSL/builtins/rcp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/rcp.hlsl
@@ -13,90 +13,94 @@
// 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 internal noundef half @
-// SPIR_NATIVE_HALF: define internal spir_func noundef half @
+export {
+
+// DXIL_NATIVE_HALF: define noundef half @
+// SPIR_NATIVE_HALF: define spir_func noundef half @
// NATIVE_HALF: %hlsl.rcp = fdiv half 0xH3C00, %{{.*}}
// NATIVE_HALF: ret half %hlsl.rcp
-// DXIL_NO_HALF: define internal noundef float @
-// SPIR_NO_HALF: define internal spir_func noundef float @
+// DXIL_NO_HALF: define noundef float @
+// SPIR_NO_HALF: define 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 internal noundef <2 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <2 x half> @
+// DXIL_NATIVE_HALF: define noundef <2 x half> @
+// SPIR_NATIVE_HALF: define 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 internal noundef <2 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <2 x float> @
+// DXIL_NO_HALF: define noundef <2 x float> @
+// SPIR_NO_HALF: define 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 internal noundef <3 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <3 x half> @
+// DXIL_NATIVE_HALF: define noundef <3 x half> @
+// SPIR_NATIVE_HALF: define 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 internal noundef <3 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <3 x float> @
+// DXIL_NO_HALF: define noundef <3 x float> @
+// SPIR_NO_HALF: define 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 internal noundef <4 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <4 x half> @
+// DXIL_NATIVE_HALF: define noundef <4 x half> @
+// SPIR_NATIVE_HALF: define 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 internal noundef <4 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <4 x float> @
+// DXIL_NO_HALF: define noundef <4 x float> @
+// SPIR_NO_HALF: define 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 internal noundef float @
-// SPIR_CHECK: define internal spir_func noundef float @
+// DXIL_CHECK: define noundef float @
+// SPIR_CHECK: define 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 internal noundef <2 x float> @
-// SPIR_CHECK: define internal spir_func noundef <2 x float> @
+// DXIL_CHECK: define noundef <2 x float> @
+// SPIR_CHECK: define 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 internal noundef <3 x float> @
-// SPIR_CHECK: define internal spir_func noundef <3 x float> @
+// DXIL_CHECK: define noundef <3 x float> @
+// SPIR_CHECK: define 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 internal noundef <4 x float> @
-// SPIR_CHECK: define internal spir_func noundef <4 x float> @
+// DXIL_CHECK: define noundef <4 x float> @
+// SPIR_CHECK: define 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 internal noundef double @
-// SPIR_CHECK: define internal spir_func noundef double @
+// DXIL_CHECK: define noundef double @
+// SPIR_CHECK: define 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 internal noundef <2 x double> @
-// SPIR_CHECK: define internal spir_func noundef <2 x double> @
+// DXIL_CHECK: define noundef <2 x double> @
+// SPIR_CHECK: define 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 internal noundef <3 x double> @
-// SPIR_CHECK: define internal spir_func noundef <3 x double> @
+// DXIL_CHECK: define noundef <3 x double> @
+// SPIR_CHECK: define 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 internal noundef <4 x double> @
-// SPIR_CHECK: define internal spir_func noundef <4 x double> @
+// DXIL_CHECK: define noundef <4 x double> @
+// SPIR_CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/reversebits.hlsl b/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
index dbfefb065f665..5bb5f4a338f0e 100644
--- a/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/reversebits.hlsl
@@ -2,26 +2,28 @@
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+export {
+
#ifdef __HLSL_ENABLE_16_BIT
-// CHECK: define internal noundef i16 @
+// CHECK: define noundef i16 @
// CHECK: call i16 @llvm.bitreverse.i16(
uint16_t test_bitreverse_ushort(uint16_t p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef <2 x i16> @
+// CHECK: define 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 internal noundef <3 x i16> @
+// CHECK: define 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 internal noundef <4 x i16> @
+// CHECK: define noundef <4 x i16> @
// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
{
@@ -29,52 +31,54 @@ uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
}
#endif
-// CHECK: define internal noundef i32 @
+// CHECK: define noundef i32 @
// CHECK: call i32 @llvm.bitreverse.i32(
int test_bitreverse_uint(uint p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef <2 x i32> @
+// CHECK: define noundef <2 x i32> @
// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
uint2 test_bitreverse_uint2(uint2 p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef <3 x i32> @
+// CHECK: define noundef <3 x i32> @
// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
uint3 test_bitreverse_uint3(uint3 p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef <4 x i32> @
+// CHECK: define noundef <4 x i32> @
// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
uint4 test_bitreverse_uint4(uint4 p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef i64 @
+// CHECK: define noundef i64 @
// CHECK: call i64 @llvm.bitreverse.i64(
uint64_t test_bitreverse_long(uint64_t p0)
{
return reversebits(p0);
}
-// CHECK: define internal noundef <2 x i64> @
+// CHECK: define 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 internal noundef <3 x i64> @
+// CHECK: define 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 internal noundef <4 x i64> @
+// CHECK: define noundef <4 x i64> @
// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
uint64_t4 test_bitreverse_long4(uint64_t4 p0)
{
return reversebits(p0);
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/round.hlsl b/clang/test/CodeGenHLSL/builtins/round.hlsl
index 692cf9e6f60ef..a597e40da761b 100644
--- a/clang/test/CodeGenHLSL/builtins/round.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/round.hlsl
@@ -6,48 +6,52 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: %elt.roundeven = call half @llvm.roundeven.f16(
// NATIVE_HALF: ret half %elt.roundeven
-// NO_HALF: define internal noundef float @"?test_round_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define 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 internal noundef <2 x float> @
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define 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 internal noundef <3 x float> @
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define 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 internal noundef <4 x float> @
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define 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 internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
index 119222125c0e1..ce286a00ccc90 100644
--- a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
@@ -13,72 +13,76 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,SPIR_CHECK,NO_HALF,SPIR_NO_HALF
-// DXIL_NATIVE_HALF: define internal noundef half @
-// SPIR_NATIVE_HALF: define internal spir_func noundef half @
+export {
+
+// DXIL_NATIVE_HALF: define noundef half @
+// SPIR_NATIVE_HALF: define spir_func noundef half @
// DXIL_NATIVE_HALF: %hlsl.rsqrt = call half @llvm.dx.rsqrt.f16(
// SPIR_NATIVE_HALF: %hlsl.rsqrt = call half @llvm.spv.rsqrt.f16(
// NATIVE_HALF: ret half %hlsl.rsqrt
-// DXIL_NO_HALF: define internal noundef float @
-// SPIR_NO_HALF: define internal spir_func noundef float @
+// DXIL_NO_HALF: define noundef float @
+// SPIR_NO_HALF: define spir_func noundef float @
// DXIL_NO_HALF: %hlsl.rsqrt = call float @llvm.dx.rsqrt.f32(
// SPIR_NO_HALF: %hlsl.rsqrt = call float @llvm.spv.rsqrt.f32(
// NO_HALF: ret float %hlsl.rsqrt
half test_rsqrt_half(half p0) { return rsqrt(p0); }
-// DXIL_NATIVE_HALF: define internal noundef <2 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <2 x half> @
+// DXIL_NATIVE_HALF: define noundef <2 x half> @
+// SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
// DXIL_NATIVE_HALF: %hlsl.rsqrt = call <2 x half> @llvm.dx.rsqrt.v2f16
// SPIR_NATIVE_HALF: %hlsl.rsqrt = call <2 x half> @llvm.spv.rsqrt.v2f16
// NATIVE_HALF: ret <2 x half> %hlsl.rsqrt
-// DXIL_NO_HALF: define internal noundef <2 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <2 x float> @
+// DXIL_NO_HALF: define noundef <2 x float> @
+// SPIR_NO_HALF: define spir_func noundef <2 x float> @
// DXIL_NO_HALF: %hlsl.rsqrt = call <2 x float> @llvm.dx.rsqrt.v2f32(
// SPIR_NO_HALF: %hlsl.rsqrt = call <2 x float> @llvm.spv.rsqrt.v2f32(
// NO_HALF: ret <2 x float> %hlsl.rsqrt
half2 test_rsqrt_half2(half2 p0) { return rsqrt(p0); }
-// DXIL_NATIVE_HALF: define internal noundef <3 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <3 x half> @
+// DXIL_NATIVE_HALF: define noundef <3 x half> @
+// SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
// DXIL_NATIVE_HALF: %hlsl.rsqrt = call <3 x half> @llvm.dx.rsqrt.v3f16
// SPIR_NATIVE_HALF: %hlsl.rsqrt = call <3 x half> @llvm.spv.rsqrt.v3f16
// NATIVE_HALF: ret <3 x half> %hlsl.rsqrt
-// DXIL_NO_HALF: define internal noundef <3 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <3 x float> @
+// DXIL_NO_HALF: define noundef <3 x float> @
+// SPIR_NO_HALF: define spir_func noundef <3 x float> @
// DXIL_NO_HALF: %hlsl.rsqrt = call <3 x float> @llvm.dx.rsqrt.v3f32(
// SPIR_NO_HALF: %hlsl.rsqrt = call <3 x float> @llvm.spv.rsqrt.v3f32(
// NO_HALF: ret <3 x float> %hlsl.rsqrt
half3 test_rsqrt_half3(half3 p0) { return rsqrt(p0); }
-// DXIL_NATIVE_HALF: define internal noundef <4 x half> @
-// SPIR_NATIVE_HALF: define internal spir_func noundef <4 x half> @
+// DXIL_NATIVE_HALF: define noundef <4 x half> @
+// SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
// DXIL_NATIVE_HALF: %hlsl.rsqrt = call <4 x half> @llvm.dx.rsqrt.v4f16
// SPIR_NATIVE_HALF: %hlsl.rsqrt = call <4 x half> @llvm.spv.rsqrt.v4f16
// NATIVE_HALF: ret <4 x half> %hlsl.rsqrt
-// DXIL_NO_HALF: define internal noundef <4 x float> @
-// SPIR_NO_HALF: define internal spir_func noundef <4 x float> @
+// DXIL_NO_HALF: define noundef <4 x float> @
+// SPIR_NO_HALF: define spir_func noundef <4 x float> @
// DXIL_NO_HALF: %hlsl.rsqrt = call <4 x float> @llvm.dx.rsqrt.v4f32(
// SPIR_NO_HALF: %hlsl.rsqrt = call <4 x float> @llvm.spv.rsqrt.v4f32(
// NO_HALF: ret <4 x float> %hlsl.rsqrt
half4 test_rsqrt_half4(half4 p0) { return rsqrt(p0); }
-// DXIL_CHECK: define internal noundef float @
-// SPIR_CHECK: define internal spir_func noundef float @
+// DXIL_CHECK: define noundef float @
+// SPIR_CHECK: define spir_func noundef float @
// DXIL_CHECK: %hlsl.rsqrt = call float @llvm.dx.rsqrt.f32(
// SPIR_CHECK: %hlsl.rsqrt = call float @llvm.spv.rsqrt.f32(
// CHECK: ret float %hlsl.rsqrt
float test_rsqrt_float(float p0) { return rsqrt(p0); }
-// DXIL_CHECK: define internal noundef <2 x float> @
-// SPIR_CHECK: define internal spir_func noundef <2 x float> @
+// DXIL_CHECK: define noundef <2 x float> @
+// SPIR_CHECK: define spir_func noundef <2 x float> @
// DXIL_CHECK: %hlsl.rsqrt = call <2 x float> @llvm.dx.rsqrt.v2f32
// SPIR_CHECK: %hlsl.rsqrt = call <2 x float> @llvm.spv.rsqrt.v2f32
// CHECK: ret <2 x float> %hlsl.rsqrt
float2 test_rsqrt_float2(float2 p0) { return rsqrt(p0); }
-// DXIL_CHECK: define internal noundef <3 x float> @
-// SPIR_CHECK: define internal spir_func noundef <3 x float> @
+// DXIL_CHECK: define noundef <3 x float> @
+// SPIR_CHECK: define spir_func noundef <3 x float> @
// DXIL_CHECK: %hlsl.rsqrt = call <3 x float> @llvm.dx.rsqrt.v3f32
// SPIR_CHECK: %hlsl.rsqrt = call <3 x float> @llvm.spv.rsqrt.v3f32
// CHECK: ret <3 x float> %hlsl.rsqrt
float3 test_rsqrt_float3(float3 p0) { return rsqrt(p0); }
-// DXIL_CHECK: define internal noundef <4 x float> @
-// SPIR_CHECK: define internal spir_func noundef <4 x float> @
+// DXIL_CHECK: define noundef <4 x float> @
+// SPIR_CHECK: define spir_func noundef <4 x float> @
// DXIL_CHECK: %hlsl.rsqrt = call <4 x float> @llvm.dx.rsqrt.v4f32
// SPIR_CHECK: %hlsl.rsqrt = call <4 x float> @llvm.spv.rsqrt.v4f32
// CHECK: ret <4 x float> %hlsl.rsqrt
float4 test_rsqrt_float4(float4 p0) { return rsqrt(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/sin.hlsl b/clang/test/CodeGenHLSL/builtins/sin.hlsl
index 58562fb6de947..a55a7a43ad4a7 100644
--- a/clang/test/CodeGenHLSL/builtins/sin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sin.hlsl
@@ -6,36 +6,40 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: call half @llvm.sin.f16(
-// NO_HALF: define internal noundef float @"?test_sin_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: call <2 x half> @llvm.sin.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_sin_half2
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: call <3 x half> @llvm.sin.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_sin_half3
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: call <4 x half> @llvm.sin.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_sin_half4
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define noundef float @
// CHECK: call float @llvm.sin.f32(
float test_sin_float(float p0) { return sin(p0); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define noundef <2 x float> @
// CHECK: call <2 x float> @llvm.sin.v2f32
float2 test_sin_float2(float2 p0) { return sin(p0); }
-// CHECK: define internal noundef <3 x float> @
+// CHECK: define noundef <3 x float> @
// CHECK: call <3 x float> @llvm.sin.v3f32
float3 test_sin_float3(float3 p0) { return sin(p0); }
-// CHECK: define internal noundef <4 x float> @
+// CHECK: define noundef <4 x float> @
// CHECK: call <4 x float> @llvm.sin.v4f32
float4 test_sin_float4(float4 p0) { return sin(p0); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
index c64df942ea71a..c191bacf0dd4a 100644
--- a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
@@ -6,48 +6,52 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @
+export {
+
+// NATIVE_HALF: define noundef half @
// NATIVE_HALF: %{{.*}} = call half @llvm.sqrt.f16(
// NATIVE_HALF: ret half %{{.*}}
-// NO_HALF: define internal noundef float @"?test_sqrt_half@@YA$halff@$halff@@Z"(
+// NO_HALF: define 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 internal noundef <2 x half> @
+// NATIVE_HALF: define noundef <2 x half> @
// NATIVE_HALF: %{{.*}} = call <2 x half> @llvm.sqrt.v2f16
// NATIVE_HALF: ret <2 x half> %{{.*}}
-// NO_HALF: define internal noundef <2 x float> @
+// NO_HALF: define 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 internal noundef <3 x half> @
+// NATIVE_HALF: define noundef <3 x half> @
// NATIVE_HALF: %{{.*}} = call <3 x half> @llvm.sqrt.v3f16
// NATIVE_HALF: ret <3 x half> %{{.*}}
-// NO_HALF: define internal noundef <3 x float> @
+// NO_HALF: define 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 internal noundef <4 x half> @
+// NATIVE_HALF: define noundef <4 x half> @
// NATIVE_HALF: %{{.*}} = call <4 x half> @llvm.sqrt.v4f16
// NATIVE_HALF: ret <4 x half> %{{.*}}
-// NO_HALF: define internal noundef <4 x float> @
+// NO_HALF: define 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 internal noundef float @
+// CHECK: define noundef float @
// CHECK: %{{.*}} = call float @llvm.sqrt.f32(
// CHECK: ret float %{{.*}}
float test_sqrt_float(float p0) { return sqrt(p0); }
-// CHECK: define internal noundef <2 x float> @
+// CHECK: define 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 internal noundef <3 x float> @
+// CHECK: define 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 internal noundef <4 x float> @
+// CHECK: define 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); }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/tan.hlsl b/clang/test/CodeGenHLSL/builtins/tan.hlsl
index aa542fac226d0..5bb9249e99d46 100644
--- a/clang/test/CodeGenHLSL/builtins/tan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tan.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_tan_half
// NATIVE_HALF: call half @llvm.tan.f16
// NO_HALF: call float @llvm.tan.f32
@@ -57,3 +59,5 @@ float3 test_tan_float3 ( float3 p0 ) {
float4 test_tan_float4 ( float4 p0 ) {
return tan ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/trunc.hlsl b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
index 7ba855aa706c3..afb42f6f2d41b 100644
--- a/clang/test/CodeGenHLSL/builtins/trunc.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
@@ -6,42 +6,46 @@
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
-// NATIVE_HALF: define internal noundef half @"?test_trunc_half
+export {
+
+// NATIVE_HALF: define noundef half @"?test_trunc_half
// NATIVE_HALF: call half @llvm.trunc.f16(
-// NO_HALF: define internal noundef float @"?test_trunc_half
+// NO_HALF: define noundef float @"?test_trunc_half
// NO_HALF: call float @llvm.trunc.f32(
half test_trunc_half(half p0) { return trunc(p0); }
-// NATIVE_HALF: define internal noundef <2 x half> @"?test_trunc_half2
+// NATIVE_HALF: define noundef <2 x half> @"?test_trunc_half2
// NATIVE_HALF: call <2 x half> @llvm.trunc.v2f16
-// NO_HALF: define internal noundef <2 x float> @"?test_trunc_half2
+// NO_HALF: define 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 internal noundef <3 x half> @"?test_trunc_half3
+// NATIVE_HALF: define noundef <3 x half> @"?test_trunc_half3
// NATIVE_HALF: call <3 x half> @llvm.trunc.v3f16
-// NO_HALF: define internal noundef <3 x float> @"?test_trunc_half3
+// NO_HALF: define 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 internal noundef <4 x half> @"?test_trunc_half4
+// NATIVE_HALF: define noundef <4 x half> @"?test_trunc_half4
// NATIVE_HALF: call <4 x half> @llvm.trunc.v4f16
-// NO_HALF: define internal noundef <4 x float> @"?test_trunc_half4
+// NO_HALF: define 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 internal noundef float @"?test_trunc_float
+// CHECK: define noundef float @"?test_trunc_float
// CHECK: call float @llvm.trunc.f32(
float test_trunc_float(float p0) { return trunc(p0); }
-// CHECK: define internal noundef <2 x float> @"?test_trunc_float2
+// CHECK: define 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 internal noundef <3 x float> @"?test_trunc_float3
+// CHECK: define 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 internal noundef <4 x float> @"?test_trunc_float4
+// CHECK: define noundef <4 x float> @"?test_trunc_float4
// CHECK: call <4 x float> @llvm.trunc.v4f32
float4 test_trunc_float4(float4 p0) { return trunc(p0); }
+
+} // export
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 799801287166a..ac0a078a7063e 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,8 +1,8 @@
// 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 internal spir_func void @main() [[A0:#[0-9]+]] {
-void main() {
+// CHECK: define spir_func void @main() [[A0:#[0-9]+]] {
+export void main() {
// CHECK: entry:
// CHECK: %[[CT_ENTRY:[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: br label %[[LABEL_WHILE_COND:.+]]
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 effc6d686a5ac..a5ec0007feace 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl
@@ -1,10 +1,10 @@
// 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 internal spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
+// CHECK: define 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() {
+export uint test_1() {
return WaveGetLaneIndex();
}
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 780250eadd325..8edf31beac496 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl
@@ -1,19 +1,19 @@
// 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 internal spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] {
+// CHECK: define 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() {
+export uint test_1() {
return WaveGetLaneIndex();
}
// CHECK-DAG: declare i32 @__hlsl_wave_get_lane_index() [[A1:#[0-9]+]]
-// CHECK: define internal spir_func noundef i32 @_Z6test_2v() [[A0]] {
+// CHECK: define 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() {
+export uint test_2() {
return test_1();
}
diff --git a/clang/test/CodeGenHLSL/cbuf.hlsl b/clang/test/CodeGenHLSL/cbuf.hlsl
index 78d9768b22fc8..86aa412d145d6 100644
--- a/clang/test/CodeGenHLSL/cbuf.hlsl
+++ b/clang/test/CodeGenHLSL/cbuf.hlsl
@@ -14,7 +14,7 @@ tbuffer A : register(t2, space1) {
double d;
}
-float foo() {
+export float foo() {
// CHECK: load float, ptr @[[CB]], align 4
// CHECK: load double, ptr getelementptr ({ float, double }, ptr @[[CB]], i32 0, i32 1), align 8
// CHECK: load float, ptr @[[TB]], align 4
diff --git a/clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl b/clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl
index 73dc376942dfb..3af6356ca9c52 100644
--- a/clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl
+++ b/clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl
@@ -16,7 +16,7 @@ namespace n1 {
}
}
-float foo() {
+export float foo() {
// CHECK: load float, ptr @[[CB]], align 4
// CHECK: load float, ptr @[[TB]], align 4
return n0::n1::a + n0::b;
diff --git a/clang/test/CodeGenHLSL/convergence/do.while.hlsl b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
index f798ea21ba53e..eba7bc17b3ee7 100644
--- a/clang/test/CodeGenHLSL/convergence/do.while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
@@ -4,11 +4,13 @@
bool cond();
void foo();
+export {
+
void test1() {
do {
} while (cond());
}
-// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: do.body:
@@ -21,7 +23,7 @@ void test2() {
foo();
} while (cond());
}
-// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: do.body:
@@ -36,7 +38,7 @@ void test3() {
foo();
} while (cond());
}
-// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: do.body:
@@ -54,7 +56,7 @@ void test4() {
}
} while (cond());
}
-// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: do.body:
@@ -74,7 +76,7 @@ void test5() {
}
} while (cond());
}
-// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: do.body:
@@ -88,3 +90,5 @@ void test5() {
// CHECK-DAG: attributes [[A0]] = { {{.*}}convergent{{.*}} }
// CHECK-DAG: attributes [[A3]] = { {{.*}}convergent{{.*}} }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/convergence/for.hlsl b/clang/test/CodeGenHLSL/convergence/for.hlsl
index f9ce4f1af7a4e..4b4a460946660 100644
--- a/clang/test/CodeGenHLSL/convergence/for.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/for.hlsl
@@ -5,12 +5,14 @@ bool cond();
bool cond2();
void foo();
+export {
+
void test1() {
for (;;) {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: for.cond:
@@ -22,7 +24,7 @@ void test2() {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: for.cond:
@@ -36,7 +38,7 @@ void test3() {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define 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 +51,7 @@ void test4() {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define 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 +65,7 @@ void test5() {
for (cond();cond2();foo()) {
}
}
-// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define 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 +83,7 @@ void test6() {
}
}
}
-// CHECK: define internal spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
+// CHECK: define 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 +108,7 @@ void test7() {
}
}
}
-// CHECK: define internal spir_func void @_Z5test7v() [[A0:#[0-9]+]] {
+// CHECK: define 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]]) ]
@@ -119,3 +121,5 @@ void test7() {
// CHECK-DAG: attributes [[A0]] = { {{.*}}convergent{{.*}} }
// CHECK-DAG: attributes [[A3]] = { {{.*}}convergent{{.*}} }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/convergence/while.hlsl b/clang/test/CodeGenHLSL/convergence/while.hlsl
index 0c92090eabc75..517fe72c65d42 100644
--- a/clang/test/CodeGenHLSL/convergence/while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/while.hlsl
@@ -4,11 +4,13 @@
bool cond();
void foo();
+export {
+
void test1() {
while (cond()) {
}
}
-// CHECK: define internal spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test1v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -20,7 +22,7 @@ void test2() {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test2v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -36,7 +38,7 @@ void test3() {
foo();
}
}
-// CHECK: define internal spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test3v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -56,7 +58,7 @@ void test4() {
}
}
}
-// CHECK: define internal spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test4v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -78,7 +80,7 @@ void test5() {
}
}
}
-// CHECK: define internal spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test5v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -102,7 +104,7 @@ void test6() {
}
}
}
-// CHECK: define internal spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @_Z5test6v() [[A0:#[0-9]+]] {
// CHECK: entry:
// CHECK: [[T0:%[0-9]+]] = call token @llvm.experimental.convergence.entry()
// CHECK: while.cond:
@@ -117,3 +119,5 @@ void test6() {
// CHECK-DAG: attributes [[A0]] = { {{.*}}convergent{{.*}} }
// CHECK-DAG: attributes [[A3]] = { {{.*}}convergent{{.*}} }
+
+} // export
diff --git a/clang/test/CodeGenHLSL/convergent-functions.hlsl b/clang/test/CodeGenHLSL/convergent-functions.hlsl
index f7c8b642272b1..2c18ccc6b142b 100644
--- a/clang/test/CodeGenHLSL/convergent-functions.hlsl
+++ b/clang/test/CodeGenHLSL/convergent-functions.hlsl
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
-void fn() {
+export void fn() {
};
// CHECK: define{{.*| }}void {{.*}}fn{{.*}}()
diff --git a/clang/test/CodeGenHLSL/float3.hlsl b/clang/test/CodeGenHLSL/float3.hlsl
index 63379349d9bd7..429cab6d254cf 100644
--- a/clang/test/CodeGenHLSL/float3.hlsl
+++ b/clang/test/CodeGenHLSL/float3.hlsl
@@ -8,6 +8,6 @@
// CHECK-NEXT:store <3 x float> %[[PARAM]], ptr %[[A_ADDR]], align 16
// CHECK-NEXT:%[[V:[0-9]+]] = load <3 x float>, ptr %[[A_ADDR]], align 16
// CHECK-NEXT:ret <3 x float> %[[V]]
-float3 foo(float3 a) {
+export float3 foo(float3 a) {
return a;
}
diff --git a/clang/test/CodeGenHLSL/half.hlsl b/clang/test/CodeGenHLSL/half.hlsl
index e83a6fc715b8a..df0eb54b87b90 100644
--- a/clang/test/CodeGenHLSL/half.hlsl
+++ b/clang/test/CodeGenHLSL/half.hlsl
@@ -16,6 +16,6 @@
// HALF:define {{.*}}half @"?foo@@YA$f16@$f16 at 0@Z"(half{{[^,]+}}, half{{[^,)]+}})
// HALF-NOT:float
// HALF:ret half %
-half foo(half a, half b) {
+export half foo(half a, half b) {
return a+b;
}
diff --git a/clang/test/CodeGenHLSL/no_int_promotion.hlsl b/clang/test/CodeGenHLSL/no_int_promotion.hlsl
index 3bf4a473e71be..d4453c386a912 100644
--- a/clang/test/CodeGenHLSL/no_int_promotion.hlsl
+++ b/clang/test/CodeGenHLSL/no_int_promotion.hlsl
@@ -5,43 +5,47 @@
// FIXME: add test for char/int8_t/uint8_t when these types are supported in HLSL.
// See https://github.com/llvm/llvm-project/issues/58453.
+export {
+
// Make sure generate i16 add.
// CHECK: add nsw i16 %
int16_t add(int16_t a, int16_t b) {
return a + b;
}
-// CHECK: define internal noundef <2 x i16> @
+// CHECK: define noundef <2 x i16> @
// CHECK: add <2 x i16>
int16_t2 add(int16_t2 a, int16_t2 b) {
return a + b;
}
-// CHECK: define internal noundef <3 x i16> @
+// CHECK: define noundef <3 x i16> @
// CHECK: add <3 x i16>
int16_t3 add(int16_t3 a, int16_t3 b) {
return a + b;
}
-// CHECK: define internal noundef <4 x i16> @
+// CHECK: define noundef <4 x i16> @
// CHECK: add <4 x i16>
int16_t4 add(int16_t4 a, int16_t4 b) {
return a + b;
}
-// CHECK: define internal noundef i16 @
+// CHECK: define noundef i16 @
// CHECK: add i16 %
uint16_t add(uint16_t a, uint16_t b) {
return a + b;
}
-// CHECK: define internal noundef <2 x i16> @
+// CHECK: define noundef <2 x i16> @
// CHECK: add <2 x i16>
uint16_t2 add(uint16_t2 a, uint16_t2 b) {
return a + b;
}
-// CHECK: define internal noundef <3 x i16> @
+// CHECK: define noundef <3 x i16> @
// CHECK: add <3 x i16>
uint16_t3 add(uint16_t3 a, uint16_t3 b) {
return a + b;
}
-// CHECK: define internal noundef <4 x i16> @
+// CHECK: define noundef <4 x i16> @
// CHECK: add <4 x i16>
uint16_t4 add(uint16_t4 a, uint16_t4 b) {
return a + b;
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/shift-mask.hlsl b/clang/test/CodeGenHLSL/shift-mask.hlsl
index a387ff90f4384..f873ec6254220 100644
--- a/clang/test/CodeGenHLSL/shift-mask.hlsl
+++ b/clang/test/CodeGenHLSL/shift-mask.hlsl
@@ -2,11 +2,13 @@
// RUN: dxil-pc-shadermodel6.3-library %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+export {
+
int shl32(int V, int S) {
return V << S;
}
-// CHECK: define internal noundef i32 @"?shl32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
+// CHECK: define 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 +16,7 @@ int shr32(int V, int S) {
return V >> S;
}
-// CHECK: define internal noundef i32 @"?shr32{{[@$?.A-Za-z0-9_]+}}"(i32 noundef %V, i32 noundef %S) #0 {
+// CHECK: define 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 +24,7 @@ int64_t shl64(int64_t V, int64_t S) {
return V << S;
}
-// CHECK: define internal noundef i64 @"?shl64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
+// CHECK: define 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 +32,8 @@ int64_t shr64(int64_t V, int64_t S) {
return V >> S;
}
-// CHECK: define internal noundef i64 @"?shr64{{[@$?.A-Za-z0-9_]+}}"(i64 noundef %V, i64 noundef %S) #0 {
+// CHECK: define 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]]
+
+} // export
diff --git a/clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl b/clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl
index eabd0faff6a87..ae3ab9ea151bc 100644
--- a/clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl
+++ b/clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl
@@ -13,6 +13,6 @@ cbuffer A {
float foo() { return a + b; }
}
-float bar() {
+export float bar() {
return foo();
}
diff --git a/clang/test/CodeGenHLSL/this-assignment-overload.hlsl b/clang/test/CodeGenHLSL/this-assignment-overload.hlsl
index 0cc9afb457b00..d2c630a1fb13d 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 internal noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
+// CHECK: define linkonce_odr 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 internal noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
+// CHECK: define linkonce_odr 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 3815b98e84953..74b4a2eb81500 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 internal noundef i32 @"?getFirst at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
+// CHECK: define linkonce_odr 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 internal noundef i32 @"?getSecond at Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 {
+// CHECK: define linkonce_odr 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 356d30a61bba2..2338b65815352 100644
--- a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
+++ b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
@@ -6,6 +6,7 @@
// valid: "spirv-unknown-vulkan-library"
// valid: define internal spir_func void @main() #0 {
+[shader("compute")]
[numthreads(1,1,1)]
void main()
{
>From 3ecf378db10c074663e251dc1addc205c27ad6d2 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Wed, 24 Jul 2024 17:15:00 -0700
Subject: [PATCH 11/12] Revert "[HLSL] Implement `export` keyword"
This reverts commit a3a8a9a265099efeae6778020546d39b8acb18c8.
---
.../clang/Basic/DiagnosticSemaKinds.td | 3 --
clang/lib/Parse/ParseDeclCXX.cpp | 8 ---
clang/lib/Parse/Parser.cpp | 2 +-
clang/lib/Sema/SemaModule.cpp | 32 ------------
clang/test/AST/HLSL/export.hlsl | 23 ---------
clang/test/CodeGenHLSL/export.hlsl | 20 --------
clang/test/SemaHLSL/export.hlsl | 50 -------------------
7 files changed, 1 insertion(+), 137 deletions(-)
delete mode 100644 clang/test/AST/HLSL/export.hlsl
delete mode 100644 clang/test/CodeGenHLSL/export.hlsl
delete mode 100644 clang/test/SemaHLSL/export.hlsl
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0f6d7b7ae9163..d3993dda9e316 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12253,9 +12253,6 @@ def warn_hlsl_availability_unavailable :
Warning<err_unavailable.Summary>,
InGroup<HLSLAvailability>, DefaultError;
-def err_hlsl_export_not_on_function : Error<
- "export declaration can only be used on functions">;
-
// Layout randomization diagnostics.
def err_non_designated_init_used : Error<
"a randomized struct can only be initialized with a designated initializer">;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 9126765f4a65b..d02548f6441f9 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -445,14 +445,6 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, DeclaratorContext Context) {
/// 'export' declaration
/// 'export' '{' declaration-seq[opt] '}'
///
-/// HLSL: Parse export function declaration.
-///
-/// export-function-declaration:
-/// 'export' function-declaration
-///
-/// export-declaration-group:
-/// 'export' '{' function-declaration-seq[opt] '}'
-///
Decl *Parser::ParseExportDeclaration() {
assert(Tok.is(tok::kw_export));
SourceLocation ExportLoc = ConsumeToken();
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index ddc8aa9b49e64..6d0cf7b174e50 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -970,7 +970,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
SingleDecl = ParseModuleImport(SourceLocation(), IS);
} break;
case tok::kw_export:
- if (getLangOpts().CPlusPlusModules || getLangOpts().HLSL) {
+ if (getLangOpts().CPlusPlusModules) {
ProhibitAttributes(Attrs);
SingleDecl = ParseExportDeclaration();
break;
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index e920b880ecb4d..ad118ac90e4aa 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -851,21 +851,6 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
CurContext->addDecl(D);
PushDeclContext(S, D);
- if (getLangOpts().HLSL) {
- // exported functions cannot be in an unnamed namespace
- for (const DeclContext *DC = CurContext; DC; DC = DC->getLexicalParent()) {
- if (const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
- if (ND->isAnonymousNamespace()) {
- Diag(ExportLoc, diag::err_export_within_anonymous_namespace);
- Diag(ND->getLocation(), diag::note_anonymous_namespace);
- D->setInvalidDecl();
- return D;
- }
- }
- }
- return D;
- }
-
// C++2a [module.interface]p1:
// An export-declaration shall appear only [...] in the purview of a module
// interface unit. An export-declaration shall not appear directly or
@@ -939,23 +924,6 @@ static bool checkExportedDeclContext(Sema &S, DeclContext *DC,
/// Check that it's valid to export \p D.
static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) {
- // HLSL: export declaration is valid only on functions
- if (S.getLangOpts().HLSL) {
- auto *FD = dyn_cast<FunctionDecl>(D);
- if (!FD) {
- if (auto *ED2 = dyn_cast<ExportDecl>(D)) {
- S.Diag(ED2->getBeginLoc(), diag::err_export_within_export);
- if (auto *ED1 = dyn_cast<ExportDecl>(D->getDeclContext()))
- S.Diag(ED1->getBeginLoc(), diag::note_export);
- }
- else {
- S.Diag(D->getBeginLoc(), diag::err_hlsl_export_not_on_function);
- }
- D->setInvalidDecl();
- return false;
- }
- }
-
// C++20 [module.interface]p3:
// [...] it shall not declare a name with internal linkage.
bool HasName = false;
diff --git a/clang/test/AST/HLSL/export.hlsl b/clang/test/AST/HLSL/export.hlsl
deleted file mode 100644
index 69c4fb2b457ac..0000000000000
--- a/clang/test/AST/HLSL/export.hlsl
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -o - %s | FileCheck %s
-
-// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}> col:1
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:13 used f1 'void ()'
-// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
-export void f1() {}
-
-// CHECK:NamespaceDecl 0x{{[0-9a-f]+}} <{{.*}}>
-// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}> col:3
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:15 used f2 'void ()'
-// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
-namespace MyNamespace {
- export void f2() {}
-}
-
-// CHECK:ExportDecl 0x{{[0-9a-f]+}} <{{.*}}>
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:10 used f3 'void ()'
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}} <{{.*}}> col:10 used f4 'void ()'
-// CHECK:CompoundStmt 0x{{[0-9a-f]+}} <{{.*}}>
-export {
- void f3() {}
- void f4() {}
-}
diff --git a/clang/test/CodeGenHLSL/export.hlsl b/clang/test/CodeGenHLSL/export.hlsl
deleted file mode 100644
index cea8875684b9e..0000000000000
--- a/clang/test/CodeGenHLSL/export.hlsl
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: dxil-pc-shadermodel6.3-library %s \
-// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-
-// CHECK: define void @"?f1@@YAXXZ"()
-export void f1() {
-}
-
-// CHECK: define void @"?f2 at MyNamespace@@YAXXZ"()
-namespace MyNamespace {
- export void f2() {
- }
-}
-
-export {
-// CHECK: define void @"?f3@@YAXXZ"()
-// CHECK: define void @"?f4@@YAXXZ"()
- void f3() {}
- void f4() {}
-}
\ No newline at end of file
diff --git a/clang/test/SemaHLSL/export.hlsl b/clang/test/SemaHLSL/export.hlsl
deleted file mode 100644
index 0cb9248f3f589..0000000000000
--- a/clang/test/SemaHLSL/export.hlsl
+++ /dev/null
@@ -1,50 +0,0 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - %s -verify
-
-export void f1();
-
-export void f1() {}
-
-namespace { // expected-note {{anonymous namespace begins here}}
- export void f2(); // expected-error {{export declaration appears within anonymous namespace}}
-}
-
-export void f3();
-
-export { // expected-note {{export block begins here}}
- void f4() {}
- export void f5() {} // expected-error {{export declaration appears within another export declaration}}
- int A; // expected-error {{export declaration can only be used on functions}}
- namespace ns { // expected-error {{export declaration can only be used on functions}}
- void f6();
- }
-}
-
-void export f7() {} // expected-error {{expected unqualified-id}}
-
-export static void f8() {} // expected-error {{declaration of 'f8' with internal linkage cannot be exported}}
-
-export void f9(); // expected-note {{previous declaration is here}}
-static void f9(); // expected-error {{static declaration of 'f9' follows non-static declaration}}
-
-static void f10(); // expected-note {{previous declaration is here}}
-export void f10(); // expected-error {{cannot export redeclaration 'f10' here since the previous declaration has internal linkage}}
-
-export float V1; // expected-error {{export declaration can only be used on functions}}
-
-static export float V2; // expected-error{{expected unqualified-id}}
-
-export static float V3 = 0; // expected-error {{export declaration can only be used on functions}}
-
-export groupshared float V4; // expected-error {{export declaration can only be used on functions}}
-
-void f6() {
- export int i; // expected-error {{expected expression}}
-}
-
-export cbuffer CB { // expected-error {{export declaration can only be used on functions}}
- int a;
-}
-
-export template<typename T> void tf1(T t) {} // expected-error {{export declaration can only be used on functions}}
-
-void f5() export {} // expected-error {{expected function body after function declarator}}
\ No newline at end of file
>From 55542fdfa03aa11459e1ad1ff69ae3cf3edc953b Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Thu, 1 Aug 2024 10:49:21 -0700
Subject: [PATCH 12/12] Keep shader entry point functions internal. Require
export keyword on all fucntion declarations. Update new tests.
---
clang/docs/HLSL/ExpectedDifferences.rst | 11 +++++++++++
clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 ++-
clang/lib/AST/ASTContext.cpp | 3 +--
clang/lib/AST/Decl.cpp | 14 ++++----------
clang/lib/CodeGen/CGHLSLRuntime.cpp | 5 +----
clang/lib/Sema/SemaDecl.cpp | 9 ++++++++-
.../standard_conversion_sequences.hlsl | 2 +-
.../test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/abs.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/acos.hlsl | 4 ++++
clang/test/CodeGenHLSL/builtins/all.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/any.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/asin.hlsl | 4 ++++
clang/test/CodeGenHLSL/builtins/atan.hlsl | 4 ++++
clang/test/CodeGenHLSL/builtins/ceil.hlsl | 2 +-
clang/test/CodeGenHLSL/builtins/cosh.hlsl | 4 ++++
clang/test/CodeGenHLSL/builtins/sinh.hlsl | 4 ++++
clang/test/CodeGenHLSL/builtins/tanh.hlsl | 4 ++++
clang/test/CodeGenHLSL/convergence/do.while.hlsl | 4 ++--
clang/test/CodeGenHLSL/convergence/for.hlsl | 4 ++--
clang/test/CodeGenHLSL/convergence/while.hlsl | 4 ++--
clang/test/CodeGenHLSL/loops/unroll.hlsl | 4 ++++
.../Availability/avail-diag-default-lib.hlsl | 2 +-
.../Availability/avail-diag-relaxed-lib.hlsl | 2 +-
.../Availability/avail-diag-strict-lib.hlsl | 2 +-
clang/test/SemaHLSL/VectorOverloadResolution.hlsl | 15 ++++-----------
clang/test/SemaHLSL/export.hlsl | 6 +++---
27 files changed, 77 insertions(+), 47 deletions(-)
diff --git a/clang/docs/HLSL/ExpectedDifferences.rst b/clang/docs/HLSL/ExpectedDifferences.rst
index e1402033f608e..fe05c4a4db7e4 100644
--- a/clang/docs/HLSL/ExpectedDifferences.rst
+++ b/clang/docs/HLSL/ExpectedDifferences.rst
@@ -132,3 +132,14 @@ argument. However, DXC does not report an error when compiling a shader library
that has an entry point function with ``[shader("stage")]`` attribute that is
also marked ``static``. Additionally, this function definition is not included
in the final DXIL.
+
+Library export functions
+------------------------
+
+All declarations of a shader library export function must be marked with the
+``export`` keyword. This is different from DXC where a function was considered
+a library export as long as one of the declarations was marked ``export``.
+
+This change aligns with C++ principle that a linkage of a function can be
+determined when a first declaration of that function is parsed and any
+subsequent redeclarations of the same function cannot change the it.
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 581434d33c5c9..af13540f4e39a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12330,7 +12330,8 @@ def err_hlsl_missing_semantic_annotation : Error<
"function or patch constant function">;
def err_hlsl_init_priority_unsupported : Error<
"initializer priorities are not supported in HLSL">;
-
+def err_redeclaration_missing_export : Error<
+ "redeclaration of exported function %0 must be marked 'export'">;
def err_hlsl_unsupported_register_type : Error<"invalid resource class specifier '%0' used; expected 'b', 's', 't', or 'u'">;
def err_hlsl_unsupported_register_number : Error<"register number should be an integer">;
def err_hlsl_expected_space : Error<"invalid space specifier '%0' used; expected 'space' followed by an integer, like space1">;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8e293ce1c2458..a50e71bd405cc 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12363,9 +12363,8 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>())
return true;
- // HLSL entry functiona are required.
+ // HLSL entry functions are required.
if (D->hasAttr<HLSLShaderAttr>())
- // FIXME: check for HLSL export attribute too
return true;
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1a626ae738dfe..fbd1f370cbe8a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -676,16 +676,10 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
} else if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
- // HLSL: functions that are not shader entry points or exported library
- // functions have internal linkage by default.
- if (Context.getLangOpts().HLSL &&
- !(FD->isInExportDeclContext() || FD->hasAttr<HLSLShaderAttr>())) {
- // Non-library shader entry points might not have an implicit
- // HLSLShaderAttr added yet so we need to check the entry point name.
- const TargetInfo &TI = Context.getTargetInfo();
- if (TI.getTriple().getEnvironment() != llvm::Triple::Library &&
- FD->getName() != TI.getTargetOpts().HLSLEntry)
- return LinkageInfo::internal();
+ // HLSL: Functions that are not exported library functions have internal linkage by default.
+ // That includes shader entry point functions, which will be wrapped by an external linkage function with unmangled C-style name during CodeGen.
+ if (Context.getLangOpts().HLSL && !(FD->isInExportDeclContext())) {
+ return LinkageInfo::internal();
}
}
assert(!isa<FieldDecl>(D) && "Didn't expect a FieldDecl!");
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 66539620ee14a..46373102250db 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -366,8 +366,6 @@ void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD,
// body have external linkage by default.
if (!FD->isDefined())
Fn->setLinkage(GlobalValue::ExternalLinkage);
-
- // FIXME: also set external linkage on exported functions
}
}
@@ -387,8 +385,7 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
setHLSLEntryAttributes(FD, EntryFn);
// Set the called function as internal linkage.
- assert(Fn->getLinkage() == GlobalValue::ExternalLinkage);
- Fn->setLinkage(GlobalValue::InternalLinkage);
+ assert(Fn->getLinkage() == GlobalValue::InternalLinkage);
BasicBlock *BB = BasicBlock::Create(Ctx, "entry", EntryFn);
IRBuilder<> B(BB);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a3f8126a9f915..602ebf9732870 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1673,8 +1673,15 @@ bool Sema::CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old) {
if (!IsNewExported && !IsOldExported)
return false;
- if (IsOldExported)
+ if (IsOldExported) {
+ if (LangOpts.HLSL && !IsNewExported) {
+ Diag(New->getLocation(), diag::err_redeclaration_missing_export) << New;
+ Diag(Old->getLocation(), diag::note_previous_declaration);
+ New->setInvalidDecl();
+ return true;
+ }
return false;
+ }
// If the Old declaration are not attached to named modules
// and the New declaration are attached to global module.
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
index 3054cdb68dc64..940efcbd537f6 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
@@ -120,4 +120,4 @@ void d4_to_b2() {
vector<bool, 2> b2 = d4;
}
-} //export
\ No newline at end of file
+} //export
diff --git a/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl b/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
index 1b05c2eba81f7..4959e7c81161f 100644
--- a/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
@@ -169,4 +169,4 @@ int AssignInt(int V){
return X;
}
-} // export
\ No newline at end of file
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/abs.hlsl b/clang/test/CodeGenHLSL/builtins/abs.hlsl
index 632bcf492612f..070a1905c78f7 100644
--- a/clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -94,4 +94,4 @@ double3 test_abs_double3(double3 p0) { return abs(p0); }
// CHECK: call <4 x double> @llvm.fabs.v4f64(
double4 test_abs_double4(double4 p0) { return abs(p0); }
-} // export
\ No newline at end of file
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/acos.hlsl b/clang/test/CodeGenHLSL/builtins/acos.hlsl
index 78a05cadfcd43..8e0e0afe869ff 100644
--- a/clang/test/CodeGenHLSL/builtins/acos.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/acos.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_acos_half
// NATIVE_HALF: call half @llvm.acos.f16
// NO_HALF: call float @llvm.acos.f32
@@ -57,3 +59,5 @@ float3 test_acos_float3 ( float3 p0 ) {
float4 test_acos_float4 ( float4 p0 ) {
return acos ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl b/clang/test/CodeGenHLSL/builtins/all.hlsl
index 1ef0c12376826..6811b6d3ebc53 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -278,4 +278,4 @@ bool test_all_bool3(bool3 p0) { return all(p0); }
// CHECK: ret i1 %hlsl.all
bool test_all_bool4(bool4 p0) { return all(p0); }
-} // export
\ No newline at end of file
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/any.hlsl b/clang/test/CodeGenHLSL/builtins/any.hlsl
index 458cbca9109b3..60b1d05c7df18 100644
--- a/clang/test/CodeGenHLSL/builtins/any.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/any.hlsl
@@ -305,4 +305,4 @@ bool test_any_bool3(bool3 p0) { return any(p0); }
// CHECK: ret i1 %hlsl.any
bool test_any_bool4(bool4 p0) { return any(p0); }
-} // export
\ No newline at end of file
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/asin.hlsl b/clang/test/CodeGenHLSL/builtins/asin.hlsl
index 1d0b457e336f5..3505046d78590 100644
--- a/clang/test/CodeGenHLSL/builtins/asin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/asin.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_asin_half
// NATIVE_HALF: call half @llvm.asin.f16
// NO_HALF: call float @llvm.asin.f32
@@ -57,3 +59,5 @@ float3 test_asin_float3 ( float3 p0 ) {
float4 test_asin_float4 ( float4 p0 ) {
return asin ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/atan.hlsl b/clang/test/CodeGenHLSL/builtins/atan.hlsl
index faee1227f3595..dcc64f6a19d90 100644
--- a/clang/test/CodeGenHLSL/builtins/atan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/atan.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_atan_half
// NATIVE_HALF: call half @llvm.atan.f16
// NO_HALF: call float @llvm.atan.f32
@@ -57,3 +59,5 @@ float3 test_atan_float3 ( float3 p0 ) {
float4 test_atan_float4 ( float4 p0 ) {
return atan ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/ceil.hlsl b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
index 49948306fc330..452a65e6d4ed3 100644
--- a/clang/test/CodeGenHLSL/builtins/ceil.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
@@ -44,4 +44,4 @@ float3 test_ceil_float3(float3 p0) { return ceil(p0); }
// CHECK: call <4 x float> @llvm.ceil.v4f32(
float4 test_ceil_float4(float4 p0) { return ceil(p0); }
-} // export
\ No newline at end of file
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/cosh.hlsl b/clang/test/CodeGenHLSL/builtins/cosh.hlsl
index a19240497b831..ddd5189e87cb8 100644
--- a/clang/test/CodeGenHLSL/builtins/cosh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/cosh.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_cosh_half
// NATIVE_HALF: call half @llvm.cosh.f16
// NO_HALF: call float @llvm.cosh.f32
@@ -57,3 +59,5 @@ float3 test_cosh_float3 ( float3 p0 ) {
float4 test_cosh_float4 ( float4 p0 ) {
return cosh ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/sinh.hlsl b/clang/test/CodeGenHLSL/builtins/sinh.hlsl
index 167f6f2242235..fd2402aeda026 100644
--- a/clang/test/CodeGenHLSL/builtins/sinh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sinh.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_sinh_half
// NATIVE_HALF: call half @llvm.sinh.f16
// NO_HALF: call float @llvm.sinh.f32
@@ -57,3 +59,5 @@ float3 test_sinh_float3 ( float3 p0 ) {
float4 test_sinh_float4 ( float4 p0 ) {
return sinh ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/builtins/tanh.hlsl b/clang/test/CodeGenHLSL/builtins/tanh.hlsl
index 6d09c8b819f91..e8908398b03a8 100644
--- a/clang/test/CodeGenHLSL/builtins/tanh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tanh.hlsl
@@ -6,6 +6,8 @@
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+export {
+
// CHECK-LABEL: test_tanh_half
// NATIVE_HALF: call half @llvm.tanh.f16
// NO_HALF: call float @llvm.tanh.f32
@@ -57,3 +59,5 @@ float3 test_tanh_float3 ( float3 p0 ) {
float4 test_tanh_float4 ( float4 p0 ) {
return tanh ( p0 );
}
+
+} // export
diff --git a/clang/test/CodeGenHLSL/convergence/do.while.hlsl b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
index eba7bc17b3ee7..c52b05cda881c 100644
--- a/clang/test/CodeGenHLSL/convergence/do.while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/do.while.hlsl
@@ -1,11 +1,11 @@
// 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
+export {
+
bool cond();
void foo();
-export {
-
void test1() {
do {
} while (cond());
diff --git a/clang/test/CodeGenHLSL/convergence/for.hlsl b/clang/test/CodeGenHLSL/convergence/for.hlsl
index 4b4a460946660..4c481d4e223da 100644
--- a/clang/test/CodeGenHLSL/convergence/for.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/for.hlsl
@@ -1,12 +1,12 @@
// 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
+export {
+
bool cond();
bool cond2();
void foo();
-export {
-
void test1() {
for (;;) {
foo();
diff --git a/clang/test/CodeGenHLSL/convergence/while.hlsl b/clang/test/CodeGenHLSL/convergence/while.hlsl
index 517fe72c65d42..212df36514eac 100644
--- a/clang/test/CodeGenHLSL/convergence/while.hlsl
+++ b/clang/test/CodeGenHLSL/convergence/while.hlsl
@@ -1,11 +1,11 @@
// 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
+export {
+
bool cond();
void foo();
-export {
-
void test1() {
while (cond()) {
}
diff --git a/clang/test/CodeGenHLSL/loops/unroll.hlsl b/clang/test/CodeGenHLSL/loops/unroll.hlsl
index 7389f21dd3472..cbf240d061bc9 100644
--- a/clang/test/CodeGenHLSL/loops/unroll.hlsl
+++ b/clang/test/CodeGenHLSL/loops/unroll.hlsl
@@ -1,6 +1,8 @@
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
+export {
+
/*** for ***/
void for_count()
{
@@ -128,3 +130,5 @@ void do_enable()
// CHECK: ![[DO_COUNT]] = !{!"llvm.loop.unroll.count", i32 16}
// CHECK: ![[DO_DISABLE]] = distinct !{![[DO_DISABLE]], ![[DISABLE]]}
// CHECK: ![[DO_ENABLE]] = distinct !{![[DO_ENABLE]], ![[ENABLE]]}
+
+} // export
diff --git a/clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl b/clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
index 6bfc8577670cc..d5bb762b4c1a4 100644
--- a/clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
+++ b/clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
@@ -114,7 +114,7 @@ class MyClass
export void exportedFunctionUnused(float f);
// Exported function with body, without export, not used
-void exportedFunctionUnused(float f) {
+export void exportedFunctionUnused(float f) {
// expected-error@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #exportedFunctionUnused_fx_call
diff --git a/clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl b/clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
index 4c9783138f670..747fbee1e4edf 100644
--- a/clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
+++ b/clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
@@ -114,7 +114,7 @@ class MyClass
export void exportedFunctionUnused(float f);
// Exported function with body, without export, not used
-void exportedFunctionUnused(float f) {
+export void exportedFunctionUnused(float f) {
// expected-warning@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #exportedFunctionUnused_fx_call
diff --git a/clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl b/clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl
index c7be5afbc2d22..8209458f73129 100644
--- a/clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl
+++ b/clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl
@@ -133,7 +133,7 @@ class MyClass
export void exportedFunctionUnused(float f);
// Exported function with body, without export, not used
-void exportedFunctionUnused(float f) {
+export void exportedFunctionUnused(float f) {
// expected-error@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #exportedFunctionUnused_fx_call
diff --git a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
index 1e455969b4590..13149b7a74fe0 100644
--- a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
+++ b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -triple dxil-unknown-shadermodel6.6-library -S -fnative-half-type -finclude-default-header -o - -ast-dump %s | FileCheck %s
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECKIR
+
+export {
+
void Fn(double2 D);
void Fn(half2 H);
@@ -73,14 +76,4 @@ void Call5(int64_t2 p0) {
Fn4(p0);
}
-// shader entry function using the Call* functions to make sure they are not
-// optimized away and get to codegen to test the IR results
-[shader("compute")]
-[numthreads(4,1,1)]
-void CSMain() {
- Call(float2(1.0f, -1.0f));
- Call2(int2(1, -1));
- Call3(half2(1.0, -1.0));
- Call4(float2(1.0, -1.0));
- Call5(int64_t2(1.0, -1.0));
-}
\ No newline at end of file
+} // export
diff --git a/clang/test/SemaHLSL/export.hlsl b/clang/test/SemaHLSL/export.hlsl
index 2d19fa561fa0a..81b3e6efba418 100644
--- a/clang/test/SemaHLSL/export.hlsl
+++ b/clang/test/SemaHLSL/export.hlsl
@@ -35,11 +35,11 @@ static void f9(); // expected-error {{static declaration of 'f9' follows non-sta
static void f10(); // expected-note {{previous declaration is here}}
export void f10(); // expected-error {{cannot export redeclaration 'f10' here since the previous declaration has internal linkage}}
-export void f11();
-void f11() {}
+export void f11(); // expected-note{{previous declaration is here}}
+void f11() {} // expected-error{{redeclaration of exported function 'f11' must be marked 'export'}}
void f12(); // expected-note{{previous declaration is here}}
-export void f12() {} // expected-error{{cannot export redeclaration 'f12' here since the previous declaration is not exported}}
+export void f12() {} // expected-error{{cannot export redeclaration 'f12' here since the previous declaration has internal linkage}}
export float V1; // expected-error {{export declaration can only be used on functions}}
More information about the cfe-commits
mailing list