Skip to content

Commit 968a917

Browse files
committed
final style changes
1 parent 06eb147 commit 968a917

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

llvm/lib/Target/NVPTX/NVVMReflect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ INITIALIZE_PASS(NVVMReflectLegacyPass, "nvvm-reflect",
9797
false)
9898

9999
// Allow users to specify additional key/value pairs to reflect. These key/value
100-
// pairs are the last to be added to the VarMap, and therefore will take
100+
// pairs are the last to be added to the ReflectMap, and therefore will take
101101
// precedence over initial values (i.e. __CUDA_FTZ from module medadata and
102102
// __CUDA_ARCH from SmVersion).
103103
static cl::list<std::string> ReflectList(
104104
"nvvm-reflect-add", cl::value_desc("name=<int>"), cl::Hidden,
105105
cl::desc("A key=value pair. Replace __nvvm_reflect(name) with value."),
106106
cl::ValueRequired);
107107

108-
// Set the VarMap with, first, the value of __CUDA_FTZ from module metadata, and
108+
// Set the ReflectMap with, first, the value of __CUDA_FTZ from module metadata, and
109109
// then the key/value pairs from the command line.
110110
void NVVMReflect::populateReflectMap(Module &M) {
111111
if (auto *Flag = mdconst::extract_or_null<ConstantInt>(

llvm/test/CodeGen/NVPTX/nvvm-reflect-options.ll

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,54 @@
11
; Test the NVVM reflect pass functionality: verifying that reflect calls are replaced with
22
; appropriate values based on command-line options. Verify that we can handle custom reflect arguments
3-
; that aren't __CUDA_ARCH or __CUDA_FTZ. If that argument is given a value on the command-line, the reflect call should be replaced with that value.
4-
; Otherwise, the reflect call should be replaced with 0.
3+
; that aren't __CUDA_ARCH or __CUDA_FTZ. If that argument is given a value on the command-line,
4+
; the reflect call should be replaced with that value. Otherwise, the reflect call should be replaced with 0.
5+
6+
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \
7+
; RUN: -nvvm-reflect-add __CUDA_FTZ=1 -nvvm-reflect-add __CUDA_ARCH=350 %s -S \
8+
; RUN: | FileCheck %s --check-prefixes=COMMON,FTZ1,ARCH350,CUSTOM-ABSENT
9+
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \
10+
; RUN: -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %s -S \
11+
; RUN: | FileCheck %s --check-prefixes=COMMON,FTZ0,ARCH520,CUSTOM-ABSENT
12+
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \
13+
; RUN: -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 \
14+
; RUN: -nvvm-reflect-add __CUSTOM_VALUE=42 %s -S \
15+
; RUN: | FileCheck %s --check-prefixes=COMMON,CUSTOM-PRESENT
16+
17+
; To ensure that command line options override module options, create a copy of this test file
18+
; with module options appended and rerun some tests.
519

6-
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda -nvvm-reflect-add __CUDA_FTZ=1 -nvvm-reflect-add __CUDA_ARCH=350 %s -S | FileCheck %s --check-prefix=CHECK-FTZ1 --check-prefix=CHECK-ARCH350 --check-prefix=CHECK-CUSTOM-ABSENT
7-
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %s -S | FileCheck %s --check-prefix=CHECK-FTZ0 --check-prefix=CHECK-ARCH520 --check-prefix=CHECK-CUSTOM-ABSENT
8-
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 -nvvm-reflect-add __CUSTOM_VALUE=42 %s -S | FileCheck %s --check-prefix=CHECK-CUSTOM-PRESENT
9-
10-
; To ensure that command line options override module options, create a copy of this test file with module options appended and rerun some tests.
11-
;
1220
; RUN: cat %s > %t.options
1321
; RUN: echo '!llvm.module.flags = !{!0}' >> %t.options
1422
; RUN: echo '!0 = !{i32 4, !"nvvm-reflect-ftz", i32 1}' >> %t.options
15-
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %t.options -S | FileCheck %s --check-prefix=CHECK-FTZ0 --check-prefix=CHECK-ARCH520
23+
; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \
24+
; RUN: -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %t.options -S \
25+
; RUN: | FileCheck %s --check-prefixes=COMMON,FTZ0,ARCH520
1626

1727
declare i32 @__nvvm_reflect(ptr)
1828
@ftz = private unnamed_addr addrspace(1) constant [11 x i8] c"__CUDA_FTZ\00"
1929
@arch = private unnamed_addr addrspace(1) constant [12 x i8] c"__CUDA_ARCH\00"
2030
@custom = private unnamed_addr addrspace(1) constant [15 x i8] c"__CUSTOM_VALUE\00"
2131

22-
; Test handling of __CUDA_FTZ reflect value
32+
; COMMON-LABEL: define i32 @test_ftz()
33+
; FTZ1: ret i32 1
34+
; FTZ0: ret i32 0
2335
define i32 @test_ftz() {
2436
%1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @ftz to ptr))
2537
ret i32 %1
2638
}
2739

28-
; CHECK-FTZ1: define i32 @test_ftz()
29-
; CHECK-FTZ1: ret i32 1
30-
; CHECK-FTZ0: define i32 @test_ftz()
31-
; CHECK-FTZ0: ret i32 0
32-
33-
; Test handling of __CUDA_ARCH reflect value
40+
; COMMON-LABEL: define i32 @test_arch()
41+
; ARCH350: ret i32 350
42+
; ARCH520: ret i32 520
3443
define i32 @test_arch() {
3544
%1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @arch to ptr))
3645
ret i32 %1
3746
}
3847

39-
; CHECK-ARCH350: define i32 @test_arch()
40-
; CHECK-ARCH350: ret i32 350
41-
; CHECK-ARCH520: define i32 @test_arch()
42-
; CHECK-ARCH520: ret i32 520
43-
44-
; Test handling of a custom reflect value that's not built into the pass
48+
; COMMON-LABEL: define i32 @test_custom()
49+
; CUSTOM-ABSENT: ret i32 0
50+
; CUSTOM-PRESENT: ret i32 42
4551
define i32 @test_custom() {
4652
%1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @custom to ptr))
4753
ret i32 %1
4854
}
49-
50-
; CHECK-CUSTOM-ABSENT: define i32 @test_custom()
51-
; CHECK-CUSTOM-ABSENT: ret i32 0
52-
; CHECK-CUSTOM-PRESENT: define i32 @test_custom()
53-
; CHECK-CUSTOM-PRESENT: ret i32 42

0 commit comments

Comments
 (0)