Skip to content

Commit d1b498e

Browse files
committed
update finalize_linkage test, update GlobalDCE comment
1 parent 08da645 commit d1b498e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

llvm/lib/Transforms/IPO/GlobalDCE.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ class GlobalDCELegacyPass : public ModulePass {
4242
bool runOnModule(Module &M) override {
4343
if (skipModule(M))
4444
return false;
45-
// Note: GlobalDCEPass does not use MAM. That
46-
// means we can get away with init and pass
47-
// as arg.
45+
// Note: GlobalDCEPass does not use any analyses, so we're safe to call the
46+
// new-pm style pass with a default-initialized analysis manager here
4847
ModuleAnalysisManager MAM;
4948
auto PA = Impl.run(M, MAM);
5049
return !PA.areAllPreserved();

llvm/test/CodeGen/DirectX/finalize_linkage.ll

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
; RUN: opt -S -passes='dxil-finalize-linkage,globaldce' -mtriple=dxil-unknown-shadermodel6.5-compute %s | FileCheck %s
1+
; RUN: opt -S -dxil-finalize-linkage -mtriple=dxil-unknown-shadermodel6.5-compute %s | FileCheck %s
22
; RUN: llc %s --filetype=asm -o - | FileCheck %s --check-prefixes=CHECK-LLC
33

44
target triple = "dxilv1.5-pc-shadermodel6.5-compute"
55

66
; DXILFinalizeLinkage changes linkage of all functions that are hidden to
7-
; internal, converts private global variables to internal linkage, and removes
8-
; unused global variables.
9-
10-
; CHECK-NOT: @aTile
11-
@aTile = hidden addrspace(3) global [4 x [1 x i32]] zeroinitializer, align 4
12-
13-
; CHECK-NOT: @bTile
14-
@bTile = hidden addrspace(3) global [1 x <1 x i32>] zeroinitializer, align 4
7+
; internal, converts private globals to internal linkage, and converts external globals
8+
; with no usage to internal linkage.
159

1610
; CHECK: @switch.table = internal unnamed_addr constant [4 x i32]
1711
@switch.table = private unnamed_addr constant [4 x i32] [i32 1, i32 257, i32 65793, i32 16843009], align 4
@@ -34,6 +28,16 @@ target triple = "dxilv1.5-pc-shadermodel6.5-compute"
3428
; CHECK: @hidden_var = hidden global i32
3529
@hidden_var = hidden global i32 1, align 4
3630

31+
; Running the whole pipeline should remove unused global variables
32+
33+
; CHECK: @aTile = internal addrspace(3) global
34+
; CHECK-LLC-NOT: @aTile
35+
@aTile = hidden addrspace(3) global [4 x [1 x i32]] zeroinitializer, align 4
36+
37+
; CHECK: @bTile = internal addrspace(3) global
38+
; CHECK-LLC-NOT: @bTile
39+
@bTile = hidden addrspace(3) global [1 x [1 x i32]] zeroinitializer, align 4
40+
3741
define void @anchor_function() #0 {
3842
entry:
3943
%0 = load i32, ptr @switch.table, align 4

0 commit comments

Comments
 (0)