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
27 lines
762 B
LLVM
27 lines
762 B
LLVM
; RUN: llc --filetype=asm %s -o - | FileCheck %s
|
|
target triple = "dxil-unknown-shadermodel6.7-library"
|
|
|
|
define i64 @test(ptr %p) {
|
|
store i32 0, ptr %p
|
|
%v = load i64, ptr %p
|
|
ret i64 %v
|
|
}
|
|
|
|
; CHECK: define internal i64 @test(ptr %p) {
|
|
; CHECK-NEXT: %1 = bitcast ptr %p to ptr
|
|
; CHECK-NEXT: store i32 0, ptr %1, align 4
|
|
; CHECK-NEXT: %2 = bitcast ptr %p to ptr
|
|
; CHECK-NEXT: %3 = load i64, ptr %2, align 8
|
|
|
|
define i64 @testGEP(ptr %p) {
|
|
%ptr = getelementptr i32, ptr %p, i32 4
|
|
%val = load i64, ptr %p
|
|
ret i64 %val
|
|
}
|
|
|
|
; CHECK: define internal i64 @testGEP(ptr %p) {
|
|
; CHECK-NEXT: %1 = bitcast ptr %p to ptr
|
|
; CHECK-NEXT: %ptr = getelementptr i32, ptr %1, i32 4
|
|
; CHECK-NEXT: %2 = bitcast ptr %p to ptr
|
|
; CHECK-NEXT: %3 = load i64, ptr %2, align 8
|