[llvm-branch-commits] [llvm] LICM: Drop -licm-force-thread-model-single in favor of the module flag (PR #223158)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 15 02:03:37 PDT 2026


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/223158

>From 789c6d9f4c0785b7bd69104087d78ad32ba468fb Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 10 Sep 2026 21:08:53 +0200
Subject: [PATCH] LICM: Drop -licm-force-thread-model-single in favor of the
 module flag

Now that the threading model is carried by the "thread-model" IR module flag,
the hidden -licm-force-thread-model-single override is redundant: a test can
select the single-threaded model by setting the module flag directly.
isThreadLocalObject reads only Module::getThreadModel.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
 llvm/lib/Transforms/Scalar/LICM.cpp                     | 6 +-----
 llvm/test/Transforms/LICM/Inputs/thread-model-single.ll | 3 +++
 llvm/test/Transforms/LICM/promote-single-thread.ll      | 4 +++-
 3 files changed, 7 insertions(+), 6 deletions(-)
 create mode 100644 llvm/test/Transforms/LICM/Inputs/thread-model-single.ll

diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index a82b249a4384c..17c1e927b14b0 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -128,10 +128,6 @@ static cl::opt<bool> ControlFlowHoisting(
     "licm-control-flow-hoisting", cl::Hidden, cl::init(false),
     cl::desc("Enable control flow (and PHI) hoisting in LICM"));
 
-static cl::opt<bool>
-    SingleThread("licm-force-thread-model-single", cl::Hidden, cl::init(false),
-                 cl::desc("Force thread model single in LICM pass"));
-
 static cl::opt<uint32_t> MaxNumUsesTraversed(
     "licm-max-num-uses-traversed", cl::Hidden, cl::init(8),
     cl::desc("Max num uses visited for identifying load "
@@ -1997,7 +1993,7 @@ bool isThreadLocalObject(const Value *Object, const Loop *L,
 
   // In a single-threaded environment, all objects are effectively thread-local.
   const Module *M = L->getHeader()->getModule();
-  return M->getThreadModel() == ThreadModel::Single || SingleThread;
+  return M->getThreadModel() == ThreadModel::Single;
 }
 
 } // namespace
diff --git a/llvm/test/Transforms/LICM/Inputs/thread-model-single.ll b/llvm/test/Transforms/LICM/Inputs/thread-model-single.ll
new file mode 100644
index 0000000000000..99880707cb0b5
--- /dev/null
+++ b/llvm/test/Transforms/LICM/Inputs/thread-model-single.ll
@@ -0,0 +1,3 @@
+; Appended to a test body to select the single-threaded thread model.
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"thread-model", !"single"}
diff --git a/llvm/test/Transforms/LICM/promote-single-thread.ll b/llvm/test/Transforms/LICM/promote-single-thread.ll
index 89935b5f1ae01..d519d82d01c5a 100644
--- a/llvm/test/Transforms/LICM/promote-single-thread.ll
+++ b/llvm/test/Transforms/LICM/promote-single-thread.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -passes=licm < %s | FileCheck %s --check-prefixes=CHECK,MT
-; RUN: opt -S -passes=licm -licm-force-thread-model-single < %s | FileCheck %s --check-prefixes=CHECK,ST
+;; The single-threaded thread model is selected by appending the "thread-model"
+;; module flag to the body.
+; RUN: cat %s %S/Inputs/thread-model-single.ll | opt -S -passes=licm | FileCheck %s --check-prefixes=CHECK,ST
 
 @g = external global i32
 @c = external constant i32



More information about the llvm-branch-commits mailing list