[llvm] [MemProf] Set -memprof-require-definition-for-promotion default to true (PR #192335)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 12:53:18 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
This was added in #<!-- -->115555. However, we cannot guarantee that all dead declarations have been stripped via `dropDeadSymbols` because it doesn't delete the declaration if there are references to it.
In #<!-- -->190876 we now have functions in ValueAsMetadata (!inline_history metadata) which can prevent function declarations from being erased. This causes memprof's ICP to create a call to a declaration that in fact has been internalized in another module, causing undefined reference linker errors.
---
Full diff: https://github.com/llvm/llvm-project/pull/192335.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-1)
- (modified) llvm/test/ThinLTO/X86/memprof-icp.ll (+5-3)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 015b6bc5caf9f..e5388d5dd07c7 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -222,7 +222,7 @@ cl::opt<bool> SupportsHotColdNew(
cl::desc("Linking with hot/cold operator new interfaces"));
static cl::opt<bool> MemProfRequireDefinitionForPromotion(
- "memprof-require-definition-for-promotion", cl::init(false), cl::Hidden,
+ "memprof-require-definition-for-promotion", cl::init(true), cl::Hidden,
cl::desc(
"Require target function definition when promoting indirect calls"));
diff --git a/llvm/test/ThinLTO/X86/memprof-icp.ll b/llvm/test/ThinLTO/X86/memprof-icp.ll
index 9fa42242cf65f..6c730f957a097 100644
--- a/llvm/test/ThinLTO/X86/memprof-icp.ll
+++ b/llvm/test/ThinLTO/X86/memprof-icp.ll
@@ -202,10 +202,12 @@
;; Run in-process ThinLTO again, but with importing disabled by setting the
;; instruction limit to 0. Ensure that the existing declarations of B::bar
-;; and B0::bar are sufficient to allow for the promotion and cloning.
+;; and B0::bar are sufficient to allow for the promotion and cloning with
+;; -memprof-require-definition-for-promotion=false.
; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
; RUN: -import-instr-limit=0 \
; RUN: -enable-memprof-indirect-call-support=true \
+; RUN: -memprof-require-definition-for-promotion=false \
; RUN: -supports-hot-cold-new \
; RUN: -r=%t/foo.o,_Z3fooR2B0j,plx \
; RUN: -r=%t/foo.o,_ZN2B03barEj.abc,plx \
@@ -237,10 +239,10 @@
; RUN: llvm-dis %t.out.2.4.opt.bc -o - | FileCheck %s --check-prefix=IR --check-prefix=IR-NOIMPORT
;; Run it gain but with -memprof-require-definition-for-promotion, and confirm
-;; that no promotions occur.
+;; that no promotions occur with the default
+;; -memprof-require-definition-for-promotion=true.
; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
; RUN: -import-instr-limit=0 \
-; RUN: -memprof-require-definition-for-promotion \
; RUN: -icp-allow-decls=false \
; RUN: -enable-memprof-indirect-call-support=true \
; RUN: -supports-hot-cold-new \
``````````
</details>
https://github.com/llvm/llvm-project/pull/192335
More information about the llvm-commits
mailing list