[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
Sat Sep 12 08:44:03 PDT 2026


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

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>

>From 25b15dd284c9d854c76b8bb068cfff856ef313bc 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/promote-single-thread.ll | 11 +++++++++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index a82b249a4384c4..17c1e927b14b00 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/promote-single-thread.ll b/llvm/test/Transforms/LICM/promote-single-thread.ll
index 89935b5f1ae01f..5660df3e39bb09 100644
--- a/llvm/test/Transforms/LICM/promote-single-thread.ll
+++ b/llvm/test/Transforms/LICM/promote-single-thread.ll
@@ -1,7 +1,9 @@
 ; 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
+; RUN: split-file %s %t
+; RUN: opt -S -passes=licm < %t/body.ll | FileCheck %s --check-prefixes=CHECK,MT
+; RUN: cat %t/body.ll %t/single.ll | opt -S -passes=licm | FileCheck %s --check-prefixes=CHECK,ST
 
+;--- body.ll
 @g = external global i32
 @c = external constant i32
 
@@ -233,3 +235,8 @@ latch:
 exit:
   ret void
 }
+
+;--- single.ll
+; Appended to the body to select the single-threaded thread model.
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"thread-model", !"single"}



More information about the llvm-branch-commits mailing list