[PATCH] D121727: [NVPTX] Integrate ptxas to LIT tests

Andrew Savonichev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 12:03:27 PDT 2022


asavonic created this revision.
asavonic added reviewers: tra, jholewinski, krisb.
Herald added a project: All.
asavonic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

ptxas is a proprietary compiler from Nvidia that can compile PTX to
machine code (SASS). It has a lot of diagnostics to catch errors
in PTX, which can be used to verify PTX output from llc.

Set -DPXTAS_EXECUTABLE=/path/to/ptxas CMake option to enable it. 
If this option is not set, then `ptxas` is substituted to `true` which
effectively disables all ptxas RUN lines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121727

Files:
  llvm/test/CodeGen/NVPTX/access-non-generic.ll
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in


Index: llvm/test/lit.site.cfg.py.in
===================================================================
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -23,6 +23,7 @@
 config.ocaml_flags = "@OCAMLFLAGS@"
 config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@
 config.go_executable = "@GO_EXECUTABLE@"
+config.ptxas_executable = "@PXTAS_EXECUTABLE@"
 config.enable_shared = @ENABLE_SHARED@
 config.enable_assertions = @ENABLE_ASSERTIONS@
 config.targets_to_build = "@TARGETS_TO_BUILD@"
Index: llvm/test/lit.cfg.py
===================================================================
--- llvm/test/lit.cfg.py
+++ llvm/test/lit.cfg.py
@@ -191,6 +191,13 @@
     ToolSubst('OrcV2CBindingsLazy', unresolved='ignore'),
     ToolSubst('OrcV2CBindingsVeryLazy', unresolved='ignore')])
 
+# Add ptxas if it is available
+ptxas_executable = 'true'
+if config.ptxas_executable:
+    ptxas_executable = config.ptxas_executable
+tools.extend([
+    ToolSubst('ptxas', ptxas_executable, unresolved='ignore')])
+
 llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
 
 # Targets
Index: llvm/test/CodeGen/NVPTX/access-non-generic.ll
===================================================================
--- llvm/test/CodeGen/NVPTX/access-non-generic.ll
+++ llvm/test/CodeGen/NVPTX/access-non-generic.ll
@@ -1,5 +1,11 @@
-; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s --check-prefix PTX
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefix PTX
+; RUN: llc < %s -march=nvptx -mcpu=sm_20 -o %t-nvptx.ptx
+; RUN: FileCheck %s --input-file %t-nvptx.ptx --check-prefix PTX
+; RUN: ptxas -c %t-nvptx.ptx -o /dev/null
+
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -o %t-nvptx64.ptx
+; RUN: FileCheck %s --input-file %t-nvptx64.ptx --check-prefix PTX
+; RUN: ptxas -c %t-nvptx64.ptx -o /dev/null
+
 ; RUN: opt -mtriple=nvptx-- < %s -S -infer-address-spaces | FileCheck %s --check-prefix IR
 ; RUN: opt -mtriple=nvptx64-- < %s -S -infer-address-spaces | FileCheck %s --check-prefix IR
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121727.415531.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220315/9db17c42/attachment.bin>


More information about the llvm-commits mailing list