llvm-project/llvm/test/CodeGen/DirectX/omit-bitcast-insert.ll
Helena Kotas db279c72f2
[HLSL] Change default linkage of HLSL functions to internal (#95331)
An HLSL function has internal linkage by default unless it is:
1. shader entry point function
2. marked with the `export` keyword
(https://github.com/llvm/llvm-project/issues/92812)
3. patch constant function (not implemented yet)

This PR adds a link-time pass `DXILFinalizeLinkage` that updates the
linkage of functions to make sure only shader entry points and exported
functions are visible from the module (have _program linkage_). All
other functions will be updated to have internal linkage.

Related spec update: microsoft/hlsl-specs#295

Fixes #llvm/llvm-project#92071
2024-08-16 10:32:10 -07:00

33 lines
772 B
LLVM

; RUN: llc --filetype=asm %s -o - | FileCheck %s
target triple = "dxil-unknown-shadermodel6.7-library"
define i64 @test(ptr %p) {
%v = load i64, ptr %p
ret i64 %v
}
; CHECK: define internal i64 @test(ptr %p) {
; CHECK-NEXT: %v = load i64, ptr %p, align 8
; CHECK-NEXT: ret i64 %v
define i64 @test2(ptr %p) {
store i64 0, ptr %p
%v = load i64, ptr %p
ret i64 %v
}
; CHECK: define internal i64 @test2(ptr %p) {
; CHECK-NEXT: store i64 0, ptr %p
; CHECK-NEXT: %v = load i64, ptr %p, align 8
; CHECK-NEXT: ret i64 %v
define i32 @test3(ptr %0) {
%2 = getelementptr i32, ptr %0, i32 4
%3 = load i32, ptr %2
ret i32 %3
}
; CHECK: define internal i32 @test3(ptr %0) {
; CHECK-NEXT: %2 = getelementptr i32, ptr %0, i32 4
; CHECK-NEXT: %3 = load i32, ptr %2