Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Sep 6, 2025

This was being used for 2 different purposes.

The TargetMachine constructor prepends +64bit based on isPPC64
triples as a mode switch. The same feature name was also explicitly
added to different processors, making it impossible to perform a pure
feature check for whether 64-bit mode is enabled ir not. i.e.,
checkFeatures("+64bit") would be true even for ppc32 triples.

The comment in tablegen suggests it's relevant to track which processors
support 64-bit mode independently of whether that's the active compile
target, so replace that with a new feature.

Copy link
Contributor Author

arsenm commented Sep 6, 2025

@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2025

@llvm/pr-subscribers-backend-powerpc

Author: Matt Arsenault (arsenm)

Changes

This was being used for 2 different purposes.

The TargetMachine constructor prepends +64bit based on isPPC64
triples as a mode switch. The same feature name was also explicitly
added to different processors, making it impossible to perform a pure
feature check for whether 64-bit mode is enabled ir not. i.e.,
checkFeatures("+64bit") would be true even for ppc32 triples.

The comment in tablegen suggests it's relevant to track which processors
support 64-bit mode independently of whether that's the active compile
target, so replace that with a new feature.


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

4 Files Affected:

  • (modified) llvm/lib/Target/PowerPC/PPC.td (+19-14)
  • (modified) llvm/lib/Target/PowerPC/PPCSubtarget.cpp (+2-5)
  • (modified) llvm/lib/Target/PowerPC/PPCSubtarget.h (-5)
  • (modified) llvm/test/CodeGen/PowerPC/i64_fp.ll (+4-4)
diff --git a/llvm/lib/Target/PowerPC/PPC.td b/llvm/lib/Target/PowerPC/PPC.td
index db6427cfe8482..386d0f65d1ed1 100644
--- a/llvm/lib/Target/PowerPC/PPC.td
+++ b/llvm/lib/Target/PowerPC/PPC.td
@@ -58,8 +58,13 @@ def DirectivePwrFuture
 
 // Specifies that the selected CPU supports 64-bit instructions, regardless of
 // whether we are in 32-bit or 64-bit mode.
-def Feature64Bit     : SubtargetFeature<"64bit","Has64BitSupport", "true",
-                                        "Enable 64-bit instructions">;
+def Feature64BitSupport : SubtargetFeature<"64bit-support", "Has64BitSupport", "true",
+                                        "Supports 64-bit instructions">;
+// 64-bit is enabled.
+def Feature64Bit     : SubtargetFeature<"64bit", "IsPPC64", "true",
+                                        "Enable 64-bit mode",
+                                        [Feature64BitSupport]>;
+
 def AIXOS: SubtargetFeature<"aix", "IsAIX", "true", "AIX OS">;
 def FeatureModernAIXAs
     : SubtargetFeature<"modern-aix-as", "HasModernAIXAs", "true",
@@ -85,7 +90,7 @@ def FeatureAltivec   : SubtargetFeature<"altivec","HasAltivec", "true",
 def FeatureSPE       : SubtargetFeature<"spe","HasSPE", "true",
                                         "Enable SPE instructions",
                                         [FeatureHardFloat]>;
-def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true", 
+def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true",
                                         "Enable Embedded Floating-Point APU 2 instructions",
                                         [FeatureSPE]>;
 def FeatureMFOCRF    : SubtargetFeature<"mfocrf","HasMFOCRF", "true",
@@ -429,7 +434,7 @@ def ProcessorFeatures {
                                                   FeaturePOPCNTD,
                                                   FeatureCMPB,
                                                   FeatureLDBRX,
-                                                  Feature64Bit,
+                                                  Feature64BitSupport,
                                                   /* Feature64BitRegs, */
                                                   FeatureBPERMD,
                                                   FeatureExtDiv,
@@ -667,13 +672,13 @@ def : ProcessorModel<"970", G5Model,
                   [Directive970, FeatureAltivec,
                    FeatureMFOCRF, FeatureFSqrt,
                    FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX,
-                   Feature64Bit /*, Feature64BitRegs */,
+                   Feature64BitSupport /*, Feature64BitRegs */,
                    FeatureMFTB]>;
 def : ProcessorModel<"g5", G5Model,
                   [Directive970, FeatureAltivec,
                    FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX,
                    FeatureFRES, FeatureFRSQRTE,
-                   Feature64Bit /*, Feature64BitRegs */,
+                   Feature64BitSupport /*, Feature64BitRegs */,
                    FeatureMFTB, DeprecatedDST]>;
 def : ProcessorModel<"e500", PPCE500Model,
                   [DirectiveE500,
@@ -694,41 +699,41 @@ def : ProcessorModel<"a2", PPCA2Model,
                    FeatureSTFIWX, FeatureLFIWAX,
                    FeatureFPRND, FeatureFPCVT, FeatureISEL,
                    FeatureSlowPOPCNTD, FeatureCMPB, FeatureLDBRX,
-                   Feature64Bit /*, Feature64BitRegs */, FeatureMFTB,
+                   Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB,
                    FeatureISA2_06]>;
 def : ProcessorModel<"pwr3", G5Model,
                   [DirectivePwr3, FeatureAltivec,
                    FeatureFRES, FeatureFRSQRTE, FeatureMFOCRF,
-                   FeatureSTFIWX, Feature64Bit]>;
+                   FeatureSTFIWX, Feature64BitSupport]>;
 def : ProcessorModel<"pwr4", G5Model,
                   [DirectivePwr4, FeatureAltivec, FeatureMFOCRF,
                    FeatureFSqrt, FeatureFRES, FeatureFRSQRTE,
-                   FeatureSTFIWX, Feature64Bit, FeatureMFTB]>;
+                   FeatureSTFIWX, Feature64BitSupport, FeatureMFTB]>;
 def : ProcessorModel<"pwr5", G5Model,
                   [DirectivePwr5, FeatureAltivec, FeatureMFOCRF,
                    FeatureFSqrt, FeatureFRE, FeatureFRES,
                    FeatureFRSQRTE, FeatureFRSQRTES,
-                   FeatureSTFIWX, Feature64Bit,
+                   FeatureSTFIWX, Feature64BitSupport,
                    FeatureMFTB, DeprecatedDST]>;
 def : ProcessorModel<"pwr5x", G5Model,
                   [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
                    FeatureFSqrt, FeatureFRE, FeatureFRES,
                    FeatureFRSQRTE, FeatureFRSQRTES,
-                   FeatureSTFIWX, FeatureFPRND, Feature64Bit,
+                   FeatureSTFIWX, FeatureFPRND, Feature64BitSupport,
                    FeatureMFTB, DeprecatedDST]>;
 def : ProcessorModel<"pwr6", G5Model,
                   [DirectivePwr6, FeatureAltivec,
                    FeatureMFOCRF, FeatureFCPSGN, FeatureFSqrt, FeatureFRE,
                    FeatureFRES, FeatureFRSQRTE, FeatureFRSQRTES,
                    FeatureRecipPrec, FeatureSTFIWX, FeatureLFIWAX, FeatureCMPB,
-                   FeatureFPRND, Feature64Bit /*, Feature64BitRegs */,
+                   FeatureFPRND, Feature64BitSupport /*, Feature64BitRegs */,
                    FeatureMFTB, DeprecatedDST]>;
 def : ProcessorModel<"pwr6x", G5Model,
                   [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
                    FeatureFCPSGN, FeatureFSqrt, FeatureFRE, FeatureFRES,
                    FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
                    FeatureSTFIWX, FeatureLFIWAX, FeatureCMPB,
-                   FeatureFPRND, Feature64Bit,
+                   FeatureFPRND, Feature64BitSupport,
                    FeatureMFTB, DeprecatedDST]>;
 def : ProcessorModel<"pwr7", P7Model, ProcessorFeatures.P7Features>;
 def : ProcessorModel<"pwr8", P8Model, ProcessorFeatures.P8Features>;
@@ -746,7 +751,7 @@ def : ProcessorModel<"ppc64", G5Model,
                   [Directive64, FeatureAltivec,
                    FeatureMFOCRF, FeatureFSqrt, FeatureFRES,
                    FeatureFRSQRTE, FeatureSTFIWX,
-                   Feature64Bit /*, Feature64BitRegs */,
+                   Feature64BitSupport /*, Feature64BitRegs */,
                    FeatureMFTB]>;
 def : ProcessorModel<"ppc64le", P8Model, ProcessorFeatures.P8Features>;
 
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
index 996b6efb320df..c63c6142a6799 100644
--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -55,10 +55,8 @@ PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU,
 PPCSubtarget::PPCSubtarget(const Triple &TT, const std::string &CPU,
                            const std::string &TuneCPU, const std::string &FS,
                            const PPCTargetMachine &TM)
-    : PPCGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT),
-      IsPPC64(TargetTriple.getArch() == Triple::ppc64 ||
-              TargetTriple.getArch() == Triple::ppc64le),
-      TM(TM), FrameLowering(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
+    : PPCGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT), TM(TM),
+      FrameLowering(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
       InstrInfo(*this), TLInfo(TM, *this) {
   TSInfo = std::make_unique<PPCSelectionDAGInfo>();
 
@@ -248,7 +246,6 @@ CodeModel::Model PPCSubtarget::getCodeModel(const TargetMachine &TM,
 }
 
 bool PPCSubtarget::isELFv2ABI() const { return TM.isELFv2ABI(); }
-bool PPCSubtarget::isPPC64() const { return TM.isPPC64(); }
 
 bool PPCSubtarget::isUsingPCRelativeCalls() const {
   return isPPC64() && hasPCRelativeMemops() && isELFv2ABI() &&
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.h b/llvm/lib/Target/PowerPC/PPCSubtarget.h
index 3c59a475c7eb6..24e464b1e40f9 100644
--- a/llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ b/llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -96,7 +96,6 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
   /// Which cpu directive was used.
   unsigned CPUDirective;
 
-  bool IsPPC64;
   bool IsLittleEndian;
 
   POPCNTDKind HasPOPCNTD;
@@ -171,10 +170,6 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
   void initSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
 
 public:
-  /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
-  ///
-  bool isPPC64() const;
-
   // useSoftFloat - Return true if soft-float option is turned on.
   bool useSoftFloat() const {
     if (isAIXABI() && !HasHardFloat)
diff --git a/llvm/test/CodeGen/PowerPC/i64_fp.ll b/llvm/test/CodeGen/PowerPC/i64_fp.ll
index b9456150df7b8..3cec87d6653a6 100644
--- a/llvm/test/CodeGen/PowerPC/i64_fp.ll
+++ b/llvm/test/CodeGen/PowerPC/i64_fp.ll
@@ -1,17 +1,17 @@
 ; fcfid and fctid should be generated when the 64bit feature is enabled, but not
 ; otherwise.
 
-; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=+64bit | \
+; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=+64bit-support | \
 ; RUN:   grep fcfid
-; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=+64bit | \
+; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=+64bit-support | \
 ; RUN:   grep fctidz
 ; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mcpu=g5 | \
 ; RUN:   grep fcfid
 ; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mcpu=g5 | \
 ; RUN:   grep fctidz
-; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=-64bit | \
+; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=-64bit-support | \
 ; RUN:   not grep fcfid
-; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=-64bit | \
+; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mattr=-64bit-support | \
 ; RUN:   not grep fctidz
 ; RUN: llc -verify-machineinstrs < %s -mattr=-vsx -mtriple=ppc32-- -mcpu=g4 | \
 ; RUN:   not grep fcfid

@arsenm arsenm marked this pull request as ready for review September 6, 2025 00:07
The way this was previously structured does not allow
access to the predicates inside of PPCRegisterInfo
This was being used for 2 different purposes.

The TargetMachine constructor prepends +64bit based on isPPC64
triples as a mode switch. The same feature name was also explicitly
added to different processors, making it impossible to perform a pure
feature check for whether 64-bit mode is enabled ir not. i.e.,
checkFeatures("+64bit") would be true even for ppc32 triples.

The comment in tablegen suggests it's relevant to track which processors
support 64-bit mode independently of whether that's the active compile
target, so replace that with a new feature.
@arsenm arsenm force-pushed the users/arsenm/ppc/move-predicate-definitions branch from fe36dae to b5ab7a9 Compare September 8, 2025 12:45
@arsenm arsenm force-pushed the users/arsenm/ppc/split-64bit-target-feature branch from f86faf6 to 0d4d26a Compare September 8, 2025 12:45
Copy link
Contributor

@lei137 lei137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me. Thx for the improvement!

Base automatically changed from users/arsenm/ppc/move-predicate-definitions to main September 16, 2025 01:18
@arsenm arsenm merged commit e5bbaa9 into main Sep 16, 2025
14 of 15 checks passed
@arsenm arsenm deleted the users/arsenm/ppc/split-64bit-target-feature branch September 16, 2025 03:43
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building llvm at step 6 "test-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/13547

Here is the relevant piece of the build log for the reference
Step 6 (test-openmp) failure: test (failure)
******************** TEST 'libarcher :: races/lock-unrelated.c' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 13
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -fopenmp  -gdwarf-4 -O1 -fsanitize=thread  -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src   /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c -o /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/deflake.bash /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp 2>&1 | tee /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp.log | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -fopenmp -gdwarf-4 -O1 -fsanitize=thread -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c -o /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp -latomic
# note: command had no output on stdout or stderr
# executed command: env TSAN_OPTIONS=ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1 /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/deflake.bash /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp
# note: command had no output on stdout or stderr
# executed command: tee /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp.log
# note: command had no output on stdout or stderr
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c
# note: command had no output on stdout or stderr
# RUN: at line 14
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -fopenmp  -gdwarf-4 -O1 -fsanitize=thread  -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src   /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c -o /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp -latomic && env ARCHER_OPTIONS="ignore_serial=1 report_data_leak=1" env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/deflake.bash /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp 2>&1 | tee /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp.log | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -fopenmp -gdwarf-4 -O1 -fsanitize=thread -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests -I /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/runtime/src /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c -o /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp -latomic
# note: command had no output on stdout or stderr
# executed command: env 'ARCHER_OPTIONS=ignore_serial=1 report_data_leak=1' env TSAN_OPTIONS=ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1 /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/deflake.bash /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp
# note: command had no output on stdout or stderr
# executed command: tee /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-bins/openmp/tools/archer/tests/races/Output/lock-unrelated.c.tmp.log
# note: command had no output on stdout or stderr
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c
# .---command stderr------------
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c:47:11: error: CHECK: expected string not found in input
# | // CHECK: ThreadSanitizer: reported {{[1-7]}} warnings
# |           ^
# | <stdin>:23:5: note: scanning from here
# | DONE
# |     ^
# | <stdin>:24:1: note: possible intended match here
# | ThreadSanitizer: thread T4 finished with ignores enabled, created at:
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            18:  #0 pthread_create /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1075:3 (lock-unrelated.c.tmp+0xa3dea) 
# |            19:  #1 __kmp_create_worker z_Linux_util.cpp (libomp.so+0xcbbf2) 
# |            20:  
# |            21: SUMMARY: ThreadSanitizer: data race /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/openmp/tools/archer/tests/races/lock-unrelated.c:31:8 in main.omp_outlined_debug__ 
# |            22: ================== 
...

@nathanchance
Copy link
Member

I have bisected a crash that folks have seen in the Linux kernel to this change.

# bad: [334013b090eef5b97cef8bc1817ed9ff67680488] Mark STATISTIC variables as maybe_unused when stats are disabled. (#159103)
# good: [3270d98641e29e25f7a34e42baf853c2816e25b0] [AArch64] Verify OPERAND_SHIFT_MSL and OPERAND_IMPLICIT_IMM_0 (#157031)
git bisect start '334013b090eef5b97cef8bc1817ed9ff67680488' '3270d98641e29e25f7a34e42baf853c2816e25b0'
# good: [9ee1f159dccbee1e19ab7584e678af9be1054e2d] [MLIR] Apply clang-tidy fixes for llvm-qualified-auto in MPIToLLVM.cpp (NFC)
git bisect good 9ee1f159dccbee1e19ab7584e678af9be1054e2d
# good: [0741209385ae62fc8c529f807c6f4f9777d94bc3] [flang][OpenMP] Guard lastprivate scoping on DO  (#157760)
git bisect good 0741209385ae62fc8c529f807c6f4f9777d94bc3
# bad: [0d927752f3f0391ee6c6444796262255963a06d9] [RISCV] Use X_X0 instead of literal 0. NFC (#158753)
git bisect bad 0d927752f3f0391ee6c6444796262255963a06d9
# good: [dbc96f41f15fc30d4fc6198eb1c2dcb57547a160] [libc++] Escape spaces in GoogleBenchmark microbenchmarks
git bisect good dbc96f41f15fc30d4fc6198eb1c2dcb57547a160
# good: [7b6db769c3470d75b0d010f16c50582ec3535dea] [NFC][DecoderEmitter] Code cleanup in `DecoderEmitter::emitTable` (#158014)
git bisect good 7b6db769c3470d75b0d010f16c50582ec3535dea
# good: [b9b92d72313b080aa83adee485d441c72a1445c8] [NFC] Rename FixedLenDecoderEmitter to just DecoderEmitter (#158766)
git bisect good b9b92d72313b080aa83adee485d441c72a1445c8
# good: [fdb06d9792afc8121e77b367cb6dce0be29b2b5b] [AMDGPU] Refactor out common exec mask opcode patterns (NFCI) (#154718)
git bisect good fdb06d9792afc8121e77b367cb6dce0be29b2b5b
# bad: [e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410] PPC: Split 64bit target feature into 64bit and 64bit-support (#157206)
git bisect bad e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410
# good: [f74184ccc9053268a5baba129fcfde554cf0d255] [MemProf] Add NodeId field to ContextNode for debugging (#158736)
git bisect good f74184ccc9053268a5baba129fcfde554cf0d255
# first bad commit: [e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410] PPC: Split 64bit target feature into 64bit and 64bit-support (#157206)

A C reproducer from cvise:

enum { false } typedef bool;
typedef int size_t;
struct vgetrandom_state {
  long generation;
} __arch_chacha20_blocks_nostack(unsigned *);
void *__cvdso_getrandom_data_buffer, *__cvdso_getrandom_data_opaque_state;
unsigned __cvdso_getrandom_data_counter[1];
size_t __cvdso_getrandom_data_len;
void getrandom_syscall(void *, size_t);
int __cvdso_getrandom_data() {
  struct vgetrandom_state *state = __cvdso_getrandom_data_opaque_state;
  size_t batch_len, orig_len = __cvdso_getrandom_data_len;
  bool in_use;
  void *orig_buffer = __cvdso_getrandom_data_buffer;
  long current_generation;
  in_use = 0;
  if (__builtin_expect(in_use, 0))
    goto fallback_syscall;
retry_generation:
  current_generation = 0;
  if (__builtin_expect(state->generation != current_generation, 0))
  more_batch:
    batch_len = 0;
  if (batch_len)
    goto retry_generation;
  __arch_chacha20_blocks_nostack(__cvdso_getrandom_data_counter);
  goto more_batch;
fallback_syscall:
  getrandom_syscall(orig_buffer, orig_len);
  return __cvdso_getrandom_data_len;
}
$ clang --target=powerpc-linux-gnu -mcpu=e5500 -c -o /dev/null vgetrandom-32.i
clang: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7677: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, SDValue, const SDNodeFlags): Assertion `N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: clang --target=powerpc-linux-gnu -mcpu=e5500 -c -o /dev/null vgetrandom-32.i
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'vgetrandom-32.i'.
4.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__cvdso_getrandom_data'
 #0 0x0000557c66f85058 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang-22+0x37e9058)
 #1 0x0000557c66f82795 llvm::sys::RunSignalHandlers() (clang-22+0x37e6795)
 #2 0x0000557c66f04666 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fb5a203e540 (/usr/lib/libc.so.6+0x3e540)
 #4 0x00007fb5a209894c (/usr/lib/libc.so.6+0x9894c)
 #5 0x00007fb5a203e410 raise (/usr/lib/libc.so.6+0x3e410)
 #6 0x00007fb5a202557a abort (/usr/lib/libc.so.6+0x2557a)
 #7 0x00007fb5a20254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
 #8 0x0000557c689ecec3 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (clang-22+0x5250ec3)
 #9 0x0000557c65b62a32 llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const::$_0::operator()() const PPCISelLowering.cpp:0:0
#10 0x0000557c65b5da4e llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const PPCISelLowering.cpp:0:0
#11 0x0000557c65b5a870 llvm::PPCTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const PPCISelLowering.cpp:0:0
#12 0x0000557c68980b38 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (clang-22+0x51e4b38)
#13 0x0000557c689a3b87 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (clang-22+0x5207b87)
#14 0x0000557c6898a233 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (clang-22+0x51ee233)
#15 0x0000557c68972144 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (clang-22+0x51d6144)
#16 0x0000557c689644b1 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (clang-22+0x51c84b1)
#17 0x0000557c68a293f5 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (clang-22+0x528d3f5)
#18 0x0000557c68a28618 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (clang-22+0x528c618)
#19 0x0000557c68a25c20 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (clang-22+0x5289c20)
#20 0x0000557c65bb589e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#21 0x0000557c68a236e0 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (clang-22+0x52876e0)
#22 0x0000557c664e2433 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (clang-22+0x2d46433)
#23 0x0000557c66a671a5 llvm::FPPassManager::runOnFunction(llvm::Function&) (clang-22+0x32cb1a5)
#24 0x0000557c66a6e942 llvm::FPPassManager::runOnModule(llvm::Module&) (clang-22+0x32d2942)
#25 0x0000557c66a67b80 llvm::legacy::PassManagerImpl::run(llvm::Module&) (clang-22+0x32cbb80)
#26 0x0000557c676d03d3 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (clang-22+0x3f343d3)
#27 0x0000557c676e5fb8 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (clang-22+0x3f49fb8)
#28 0x0000557c68d15ec9 clang::ParseAST(clang::Sema&, bool, bool) (clang-22+0x5579ec9)
#29 0x0000557c67c2a956 clang::FrontendAction::Execute() (clang-22+0x448e956)
#30 0x0000557c67b8b8fd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang-22+0x43ef8fd)
#31 0x0000557c67d00a9b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang-22+0x4564a9b)
#32 0x0000557c65b11a83 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang-22+0x2375a83)
#33 0x0000557c65b0da3f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000557c679b01d9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#35 0x0000557c66f0434e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang-22+0x376834e)
#36 0x0000557c679afa13 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang-22+0x4213a13)
#37 0x0000557c6796ab23 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang-22+0x41ceb23)
#38 0x0000557c6796ad47 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (clang-22+0x41ced47)
#39 0x0000557c67988178 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang-22+0x41ec178)
#40 0x0000557c65b0d122 clang_main(int, char**, llvm::ToolContext const&) (clang-22+0x2371122)
#41 0x0000557c65b1e3a7 main (clang-22+0x23823a7)
#42 0x00007fb5a2027675 (/usr/lib/libc.so.6+0x27675)
#43 0x00007fb5a2027729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#44 0x0000557c65b0b465 _start (clang-22+0x236f465)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 22.0.0git (https://github.com/llvm/llvm-project.git e5bbaa9c8fb6e06dbcbd39404039cc5d31df4410)
...

llvm-reduce took it much further but I am not sure if it is legitimate?

target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32"
target triple = "powerpc-unknown-linux-gnu"

define i32 @__cvdso_getrandom_data() #0 {
entry:
  br label %if.end4

if.end4:                                          ; preds = %if.end4, %entry
  call void null(ptr null, ptr null)
  br label %if.end4
}

attributes #0 = { "target-cpu"="e5500" }
llc: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7677: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, SDValue, const SDNodeFlags): Assertion `N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: llc -o /dev/null reduced.ll
1.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__cvdso_getrandom_data'
 #0 0x0000563a0a3ffad8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llc+0x354bad8)
 #1 0x0000563a0a3fd1a5 llvm::sys::RunSignalHandlers() (llc+0x35491a5)
 #2 0x0000563a0a400881 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007fb29103e540 (/usr/lib/libc.so.6+0x3e540)
 #4 0x00007fb29109894c (/usr/lib/libc.so.6+0x9894c)
 #5 0x00007fb29103e410 raise (/usr/lib/libc.so.6+0x3e410)
 #6 0x00007fb29102557a abort (/usr/lib/libc.so.6+0x2557a)
 #7 0x00007fb2910254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
 #8 0x0000563a0a19eee3 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (llc+0x32eaee3)
 #9 0x0000563a0898c8f2 llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const::$_0::operator()() const PPCISelLowering.cpp:0:0
#10 0x0000563a0898790e llvm::PPCTargetLowering::LowerCall_64SVR4(llvm::SDValue, llvm::SDValue, llvm::PPCTargetLowering::CallFlags, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::SmallVectorImpl<llvm::SDValue> const&, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::CallBase const*) const PPCISelLowering.cpp:0:0
#11 0x0000563a08984730 llvm::PPCTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const PPCISelLowering.cpp:0:0
#12 0x0000563a0a126178 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (llc+0x3272178)
#13 0x0000563a0a149247 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (llc+0x3295247)
#14 0x0000563a0a12f873 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (llc+0x327b873)
#15 0x0000563a0a117124 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (llc+0x3263124)
#16 0x0000563a0a109421 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (llc+0x3255421)
#17 0x0000563a0a1de235 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (llc+0x332a235)
#18 0x0000563a0a1dd8cb llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (llc+0x33298cb)
#19 0x0000563a0a1daa60 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (llc+0x3326a60)
#20 0x0000563a089dfa4e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#21 0x0000563a0a1d8520 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (llc+0x3324520)
#22 0x0000563a093f2e53 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (llc+0x253ee53)
#23 0x0000563a0996d9d5 llvm::FPPassManager::runOnFunction(llvm::Function&) (llc+0x2ab99d5)
#24 0x0000563a09975382 llvm::FPPassManager::runOnModule(llvm::Module&) (llc+0x2ac1382)
#25 0x0000563a0996e440 llvm::legacy::PassManagerImpl::run(llvm::Module&) (llc+0x2aba440)
#26 0x0000563a0890fe9e compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#27 0x0000563a0890d67d main (llc+0x1a5967d)
#28 0x00007fb291027675 (/usr/lib/libc.so.6+0x27675)
#29 0x00007fb291027729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#30 0x0000563a089095e5 _start (llc+0x1a555e5)

@arsenm
Copy link
Contributor Author

arsenm commented Sep 20, 2025

I have bisected a crash that folks have seen in the Linux kernel to this change.

Fix in #159893

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.

6 participants