Skip to content

Revert "Revert "[AMDGPU][LTO] Assume closed world after linking (#105845)" (#106000)" #106001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gandhi56
Copy link
Contributor

This reverts commit 4b6c064.

Add a requirement for an amdgpu target in the test.

…#105845)" (llvm#106000)"

This reverts commit 4b6c064.

Add a requirement for an amdgpu target in the test.
@llvmbot llvmbot added backend:AMDGPU LTO Link time optimization (regular/full LTO or ThinLTO) labels Aug 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2024

@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-lto

Author: Anshil Gandhi (gandhi56)

Changes

This reverts commit 4b6c064.

Add a requirement for an amdgpu target in the test.


Full diff: https://github.com/llvm/llvm-project/pull/106001.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp (+4)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+6-2)
  • (added) llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll (+12)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index d65e0ae92308e6..81932cc2c3c3bc 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -1066,6 +1066,10 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
 
   Attributor A(Functions, InfoCache, AC);
 
+  LLVM_DEBUG(dbgs() << "Module " << M.getName() << " is "
+                    << (AC.IsClosedWorldModule ? "" : "not ")
+                    << "assumed to be a closed world.\n");
+
   for (Function &F : M) {
     if (F.isIntrinsic())
       continue;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 7ac7b3315bb972..307774ea3da9eb 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -760,8 +760,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
         // module is partitioned for codegen.
         if (EnableLowerModuleLDS)
           PM.addPass(AMDGPULowerModuleLDSPass(*this));
-        if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
-          PM.addPass(AMDGPUAttributorPass(*this));
+
+        if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) {
+          AMDGPUAttributorOptions Opts;
+          Opts.IsClosedWorld = true;
+          PM.addPass(AMDGPUAttributorPass(*this, Opts));
+        }
       });
 
   PB.registerRegClassFilterParsingCallback(
diff --git a/llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll b/llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll
new file mode 100644
index 00000000000000..42640f94537640
--- /dev/null
+++ b/llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll
@@ -0,0 +1,12 @@
+; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
+; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK
+
+; REQUIRES: amdgpu-registered-target
+
+target triple = "amdgcn-amd-amdhsa"
+
+; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
+; POST-LINK: Module {{.*}} is assumed to be a closed world.
+define hidden noundef i32 @_Z3foov() {
+  ret i32 1
+}

@gandhi56 gandhi56 merged commit 033e225 into llvm:main Aug 25, 2024
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 25, 2024

LLVM Buildbot has detected a new failure on builder clang-x64-windows-msvc running on windows-gcebot2 while building llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/63/builds/1213

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/clang-windows.py ...' (failure)
...
  Passed           : 37748 (99.09%)
  Expectedly Failed:    34 (0.09%)
[94/95] Running the LLVM regression tests
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using ld.lld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\ld.lld.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using lld-link: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\lld-link.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using ld64.lld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\ld64.lld.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using wasm-ld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\wasm-ld.exe
-- Testing: 54702 tests, 32 workers --
Testing: 
FAIL: LLVM :: LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll (1 of 54702)
******************** TEST 'LLVM :: LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe -O3 -debug-only=amdgpu-attributor -S -o - C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll 2>&1 | c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\filecheck.exe C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll --check-prefix=PRE-LINK
# executed command: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe' -O3 -debug-only=amdgpu-attributor -S -o - 'C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll'
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\filecheck.exe' 'C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll' --check-prefix=PRE-LINK
# .---command stderr------------
# | C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll:8:13: error: PRE-LINK: expected string not found in input
# | ; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
# |             ^
# | <stdin>:1:1: note: scanning from here
# | opt.exe: Unknown command line argument '-debug-only=amdgpu-attributor'. Try: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe --help'
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |          1: opt.exe: Unknown command line argument '-debug-only=amdgpu-attributor'. Try: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe --help' 
# | check:8     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |          2: opt.exe: Did you mean '--debug-pass=amdgpu-attributor'? 
# | check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Step 8 (stage 1 check) failure: stage 1 check (failure)
...
  Passed           : 37748 (99.09%)
  Expectedly Failed:    34 (0.09%)
[94/95] Running the LLVM regression tests
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using ld.lld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\ld.lld.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using lld-link: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\lld-link.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using ld64.lld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\ld64.lld.exe
llvm-lit.py: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\utils\lit\lit\llvm\config.py:508: note: using wasm-ld: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\wasm-ld.exe
-- Testing: 54702 tests, 32 workers --
Testing: 
FAIL: LLVM :: LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll (1 of 54702)
******************** TEST 'LLVM :: LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe -O3 -debug-only=amdgpu-attributor -S -o - C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll 2>&1 | c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\filecheck.exe C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll --check-prefix=PRE-LINK
# executed command: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe' -O3 -debug-only=amdgpu-attributor -S -o - 'C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll'
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\filecheck.exe' 'C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll' --check-prefix=PRE-LINK
# .---command stderr------------
# | C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll:8:13: error: PRE-LINK: expected string not found in input
# | ; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
# |             ^
# | <stdin>:1:1: note: scanning from here
# | opt.exe: Unknown command line argument '-debug-only=amdgpu-attributor'. Try: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe --help'
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\test\LTO\AMDGPU\gpu-rdc-amdgpu-attrs.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |          1: opt.exe: Unknown command line argument '-debug-only=amdgpu-attributor'. Try: 'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\opt.exe --help' 
# | check:8     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |          2: opt.exe: Did you mean '--debug-pass=amdgpu-attributor'? 
# | check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

@@ -0,0 +1,12 @@
; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-debug-only won't work wth LLVM_ENABLE_ASSERTIONS=OFF.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, do you know how I could add a requirement for assertions then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a PR: #106027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU LTO Link time optimization (regular/full LTO or ThinLTO)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants