Skip to content

[lld-link] Change /lldemit:llvm to use the pre-codegen module #98589

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

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Jul 12, 2024

This matches ELF (#97480). clang cc1 -emit-llvm and -emit-llvm-bc for
ThinLTO backend compilation also uses PreCodeGenModuleHook.

While here, replace deprecated %T with %t.

Created using spr 1.3.5-bogner
@MaskRay MaskRay changed the title [COFF] Change /lldemit:llvm to use the pre-codegen module [lld-link] Change /lldemit:llvm to use the pre-codegen module Jul 12, 2024
@MaskRay MaskRay requested review from mstorsjo and aganea July 12, 2024 05:32
@llvmbot
Copy link
Member

llvmbot commented Jul 12, 2024

@llvm/pr-subscribers-platform-windows
@llvm/pr-subscribers-lld-coff

@llvm/pr-subscribers-lld

Author: Fangrui Song (MaskRay)

Changes

This matches ELF (#97480). clang cc1 -emit-llvm and -emit-llvm-bc for
ThinLTO backend compilation also uses PreCodeGenModuleHook.

While here, replace deprecated %T with %t.


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

2 Files Affected:

  • (modified) lld/COFF/LTO.cpp (+1-1)
  • (modified) lld/test/COFF/lto-emit-llvm.ll (+5-4)
diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index be49aa6e8bb3d..5c881bc01c663 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -91,7 +91,7 @@ lto::Config BitcodeCompiler::createConfig() {
   c.TimeTraceGranularity = ctx.config.timeTraceGranularity;
 
   if (ctx.config.emit == EmitKind::LLVM) {
-    c.PostInternalizeModuleHook = [this](size_t task, const Module &m) {
+    c.PreCodeGenModuleHook = [this](size_t task, const Module &m) {
       if (std::unique_ptr<raw_fd_ostream> os =
               openLTOOutputFile(ctx.config.outputFile))
         WriteBitcodeToFile(m, *os, false);
diff --git a/lld/test/COFF/lto-emit-llvm.ll b/lld/test/COFF/lto-emit-llvm.ll
index 985058de10a48..3ba6cf722e97f 100644
--- a/lld/test/COFF/lto-emit-llvm.ll
+++ b/lld/test/COFF/lto-emit-llvm.ll
@@ -1,10 +1,11 @@
 ; REQUIRES: x86
-; RUN: llvm-as -o %T/lto.obj %s
+; RUN: rm -rf %t && mkdir %t
+; RUN: llvm-as -o %t/lto.obj %s
 
-; RUN: lld-link /lldemit:llvm /out:%T/lto.bc /entry:main /subsystem:console %T/lto.obj
-; RUN: llvm-dis %T/lto.bc -o - | FileCheck %s
+; RUN: lld-link /lldemit:llvm /out:%t/lto.bc /entry:main /subsystem:console %t/lto.obj
+; RUN: llvm-dis %t/lto.bc -o - | FileCheck %s
 
-; CHECK: define void @main()
+; CHECK: define void @main() local_unnamed_addr
 
 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-windows-msvc"

@MaskRay
Copy link
Member Author

MaskRay commented Jul 16, 2024

Ping:) This is a trivial change.

@MaskRay MaskRay merged commit cf6233f into main Jul 17, 2024
11 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/coff-change-lldemitllvm-to-use-the-pre-codegen-module branch July 17, 2024 00:56
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
This matches ELF (#97480). clang cc1 -emit-llvm and -emit-llvm-bc for
ThinLTO backend compilation also uses `PreCodeGenModuleHook`.

While here, replace deprecated %T with %t.

Pull Request: #98589

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants