[PATCH] D122890: Refine tls-load-hoista llvm option

Xiang Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 03:19:14 PDT 2022


xiangzhangllvm created this revision.
xiangzhangllvm added reviewers: LuoYuanke, pengfei.
Herald added subscribers: jdoerfert, hiraditya.
Herald added a project: All.
xiangzhangllvm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Refine tls-load-hoista llvm option from string value to bool


https://reviews.llvm.org/D122890

Files:
  llvm/docs/LangRef.rst
  llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
  llvm/test/CodeGen/X86/tls-loads-control.ll
  llvm/test/CodeGen/X86/tls-loads-control2.ll
  llvm/test/CodeGen/X86/tls-loads-control3.ll


Index: llvm/test/CodeGen/X86/tls-loads-control3.ll
===================================================================
--- llvm/test/CodeGen/X86/tls-loads-control3.ll
+++ llvm/test/CodeGen/X86/tls-loads-control3.ll
@@ -1,6 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --tls-load-hoist=optimize -o - %s | FileCheck %s --check-prefix=HOIST0
-; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --tls-load-hoist=non-optimize -o - %s | FileCheck %s --check-prefix=HOIST2
+; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --tls-load-hoist=true -o - %s | FileCheck %s --check-prefix=HOIST0
 ; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic -o - %s | FileCheck %s --check-prefix=HOIST2
 
 ; This test has no module flag {"tls-load-hoist", i32 0}, so use --tls-load-hoist=x
Index: llvm/test/CodeGen/X86/tls-loads-control2.ll
===================================================================
--- llvm/test/CodeGen/X86/tls-loads-control2.ll
+++ llvm/test/CodeGen/X86/tls-loads-control2.ll
@@ -1,5 +1,4 @@
-; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic --tls-load-hoist=optimize -o - %s | FileCheck %s --check-prefix=HOIST0
-; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic --tls-load-hoist=non-optimize -o - %s | FileCheck %s --check-prefix=HOIST2
+; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic --tls-load-hoist=true -o - %s | FileCheck %s --check-prefix=HOIST0
 ; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic -o - %s | FileCheck %s --check-prefix=HOIST2
 
 $_ZTW5thl_x = comdat any
Index: llvm/test/CodeGen/X86/tls-loads-control.ll
===================================================================
--- llvm/test/CodeGen/X86/tls-loads-control.ll
+++ llvm/test/CodeGen/X86/tls-loads-control.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --tls-load-hoist=optimize --stop-after=tlshoist -o - %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --tls-load-hoist=true --stop-after=tlshoist -o - %s | FileCheck %s
 ; RUN: llc -mtriple=x86_64-unknown-unknown -O2 --relocation-model=pic --stop-after=tlshoist -o - %s | FileCheck %s
 
 ; This test come from compiling clang/test/CodeGen/intel/tls_loads.cpp with:
Index: llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
+++ llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
@@ -40,16 +40,10 @@
 
 #define DEBUG_TYPE "tlshoist"
 
-// TODO: Support "strict" model if we need to strictly load TLS address,
-// because "non-optimize" may also do some optimization in other passes.
-static cl::opt<std::string> TLSLoadHoist(
-    "tls-load-hoist",
-    cl::desc(
-        "hoist the TLS loads in PIC model: "
-        "tls-load-hoist=optimize: Eleminate redundant TLS load(s)."
-        "tls-load-hoist=strict: Strictly load TLS address before every use."
-        "tls-load-hoist=non-optimize: Generally load TLS before use(s)."),
-    cl::init("non-optimize"), cl::Hidden);
+static cl::opt<bool> TLSLoadHoist(
+    "tls-load-hoist", cl::init(false), cl::Hidden,
+    cl::desc("hoist the TLS loads in PIC model to eleminate redundant "
+             "TLS address calculation."));
 
 namespace {
 
@@ -282,8 +276,7 @@
   if (Fn.hasOptNone())
     return false;
 
-  if (TLSLoadHoist != "optimize" &&
-      !Fn.getAttributes().hasFnAttr("tls-load-hoist"))
+  if (!TLSLoadHoist && !Fn.getAttributes().hasFnAttr("tls-load-hoist"))
     return false;
 
   this->LI = &LI;
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2125,7 +2125,7 @@
 
 ``"tls-load-hoist"``
     This attribute indicates that the function will try to reduce redundant
-    tls address caculation by hoisting tls variable.
+    tls address calculation by hoisting tls variable.
 
 ``uwtable[(sync|async)]``
     This attribute indicates that the ABI being targeted requires that


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122890.419697.patch
Type: text/x-patch
Size: 4279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220401/0c1c2b79/attachment.bin>


More information about the llvm-commits mailing list