llvm-project/llvm/test/CodeGen/DirectX/conflicting-bitcast-insert.ll
Greg Roth ab75180501
[DirectX] Remove trivially dead functions at linkage finalize (#106146)
Functions are not removed even when made internal by
DXILFinalizeLinkage. The removal code is called from alwaysinliner and
globalopt, which are invoked too early to remove functions made internal
by this pass.

This adds a check similar to that in alwaysinliner that removes
trivially dead functions after being marked internal. It refactors that
code a bit to make it simpler including reversing what is stored int he
work queue.

Tests both the pass in isolation and the full i0nlining, linkage
finalization and function removal steps.

Fixes #106139
2024-10-17 12:54:52 -06:00

29 lines
820 B
LLVM

; RUN: llc --filetype=asm %s -o - | FileCheck %s
target triple = "dxil-unknown-shadermodel6.7-library"
define i64 @test(ptr %p) #0 {
store i32 0, ptr %p
%v = load i64, ptr %p
ret i64 %v
}
; CHECK: define i64 @test(ptr %p) #0 {
; 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) #0 {
%ptr = getelementptr i32, ptr %p, i32 4
%val = load i64, ptr %p
ret i64 %val
}
attributes #0 = { convergent norecurse nounwind "hlsl.export"}
; CHECK: define i64 @testGEP(ptr %p) #0 {
; 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