Skip to content

Commit b1bcb98

Browse files
committed
Comments + adapt inline asm test w/o CL opt
1 parent 5dd03a6 commit b1bcb98

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ static cl::opt<bool> NoExternalizeOnAddrTaken(
109109
cl::desc(
110110
"disables externalization of functions whose addresses are taken"));
111111

112-
static cl::opt<bool> InlineAsmIsIndirectCall(
113-
"amdgpu-module-splitting-inline-asm-is-indirect-call", cl::Hidden,
114-
cl::desc("consider inline assembly as an indirect call"));
115-
116112
static cl::opt<std::string>
117113
ModuleDotCfgOutput("amdgpu-module-splitting-print-module-dotcfg",
118114
cl::Hidden,
@@ -519,8 +515,9 @@ void SplitGraph::buildGraph(CallGraph &CG) {
519515
// Keep track of this function if it contains an indirect call and/or if it
520516
// can be indirectly called.
521517
if (CallsExternal) {
522-
LLVM_DEBUG(dbgs() << " [!] callgraph is incomplete for " << Fn.getName()
523-
<< " - analyzing function\n");
518+
LLVM_DEBUG(dbgs() << " [!] callgraph is incomplete for ";
519+
Fn.printAsOperand(dbgs());
520+
dbgs() << " - analyzing function\n");
524521

525522
bool HasIndirectCall = false;
526523
for (const auto &Inst : instructions(Fn)) {
@@ -530,8 +527,6 @@ void SplitGraph::buildGraph(CallGraph &CG) {
530527
// inline assembly can be ignored, unless InlineAsmIsIndirectCall is
531528
// true.
532529
if (CB->isInlineAsm()) {
533-
if (InlineAsmIsIndirectCall)
534-
HasIndirectCall = true;
535530
LLVM_DEBUG(dbgs() << " found inline assembly\n");
536531
continue;
537532
}
@@ -1372,11 +1367,9 @@ static void splitAMDGPUModule(
13721367
for (auto &Fn : M) {
13731368
// TODO: Should aliases count? Probably not but they're so rare I'm not
13741369
// sure it's worth fixing.
1375-
if (Fn.hasAddressTaken()) {
1376-
if (Fn.hasLocalLinkage()) {
1377-
LLVM_DEBUG(dbgs() << "[externalize] " << Fn.getName()
1378-
<< " because its address is taken\n");
1379-
}
1370+
if (Fn.hasLocalLinkage() && Fn.hasAddressTaken()) {
1371+
LLVM_DEBUG(dbgs() << "[externalize] "; Fn.printAsOperand(dbgs());
1372+
dbgs() << " because its address is taken\n");
13801373
externalize(Fn);
13811374
}
13821375
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; REQUIRES: asserts
2+
3+
; RUN: llvm-split -o %t %s -j 2 -mtriple amdgcn-amd-amdhsa -amdgpu-module-splitting-no-externalize-address-taken -debug-only=amdgpu-split-module 2>&1 | FileCheck %s
4+
5+
; CHECK: [!] callgraph is incomplete for ptr @A - analyzing function
6+
; CHECK-NEXT: found inline assembly
7+
; CHECK-NOT: indirect call found
8+
9+
@addrthief = global [2 x ptr] [ptr @HelperA, ptr @HelperB]
10+
11+
define internal void @HelperA() {
12+
ret void
13+
}
14+
15+
define internal void @HelperB() {
16+
ret void
17+
}
18+
19+
define amdgpu_kernel void @A() {
20+
call void asm sideeffect "v_mov_b32 v0, 7", "~{v0}"()
21+
call void @HelperA()
22+
ret void
23+
}
24+
25+
define amdgpu_kernel void @B(ptr %out) {
26+
call void @HelperB()
27+
ret void
28+
}

llvm/test/tools/llvm-split/AMDGPU/indirect-call-inline-asm.ll

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22
; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 --implicit-check-not=define %s
33
; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 --implicit-check-not=define %s
44

5-
; RUN: llvm-split -o %t_as_indirect %s -j 2 -mtriple amdgcn-amd-amdhsa -amdgpu-module-splitting-no-externalize-address-taken -amdgpu-module-splitting-inline-asm-is-indirect-call
6-
; RUN: llvm-dis -o - %t_as_indirect0 | FileCheck --check-prefix=CHECK-INDIRECT0 --implicit-check-not=define %s
7-
; RUN: llvm-dis -o - %t_as_indirect1 | FileCheck --check-prefix=CHECK-INDIRECT1 --implicit-check-not=define %s
8-
95
; CHECK0: define internal void @HelperB
106
; CHECK0: define amdgpu_kernel void @B
117

128
; CHECK1: define internal void @HelperA()
139
; CHECK1: define amdgpu_kernel void @A()
1410

15-
; CHECK-INDIRECT0: define internal void @HelperB
16-
; CHECK-INDIRECT0: define amdgpu_kernel void @B
17-
18-
; CHECK-INDIRECT1: define internal void @HelperA()
19-
; CHECK-INDIRECT1: define internal void @HelperB()
20-
; CHECK-INDIRECT1: define amdgpu_kernel void @A()
21-
2211
@addrthief = global [2 x ptr] [ptr @HelperA, ptr @HelperB]
2312

2413
define internal void @HelperA() {

0 commit comments

Comments
 (0)