Skip to content

Conversation

@mingmingl-llvm
Copy link
Contributor

Reverts #158460 due to buildbot failures

@mingmingl-llvm mingmingl-llvm marked this pull request as ready for review September 16, 2025 19:51
@mingmingl-llvm mingmingl-llvm merged commit 9277bcd into main Sep 16, 2025
10 of 12 checks passed
@mingmingl-llvm mingmingl-llvm deleted the revert-158460-users/mingmingl-llvm/unittest branch September 16, 2025 19:51
@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-llvm-ir

Author: Mingming Liu (mingmingl-llvm)

Changes

Reverts llvm/llvm-project#158460 due to buildbot failures


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

7 Files Affected:

  • (modified) llvm/include/llvm/IR/GlobalObject.h (+2-4)
  • (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/StaticDataAnnotator.cpp (+2-1)
  • (modified) llvm/lib/IR/Globals.cpp (+1-13)
  • (modified) llvm/lib/Transforms/Instrumentation/MemProfUse.cpp (+3-2)
  • (modified) llvm/unittests/IR/CMakeLists.txt (-1)
  • (removed) llvm/unittests/IR/GlobalObjectTest.cpp (-80)
diff --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h
index e273387807cf6..08a02b42bdc14 100644
--- a/llvm/include/llvm/IR/GlobalObject.h
+++ b/llvm/include/llvm/IR/GlobalObject.h
@@ -121,10 +121,8 @@ class GlobalObject : public GlobalValue {
   /// appropriate default object file section.
   LLVM_ABI void setSection(StringRef S);
 
-  /// If existing prefix is different from \p Prefix, set it to \p Prefix. If \p
-  /// Prefix is empty, the set clears the existing metadata. Returns true if
-  /// section prefix changed and false otherwise.
-  LLVM_ABI bool setSectionPrefix(StringRef Prefix);
+  /// Set the section prefix for this global object.
+  LLVM_ABI void setSectionPrefix(StringRef Prefix);
 
   /// Get the section prefix for this global object.
   LLVM_ABI std::optional<StringRef> getSectionPrefix() const;
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 92d87681c9adc..9db4c9e5e2807 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -583,23 +583,23 @@ bool CodeGenPrepare::_run(Function &F) {
   // if requested.
   if (BBSectionsGuidedSectionPrefix && BBSectionsProfileReader &&
       BBSectionsProfileReader->isFunctionHot(F.getName())) {
-    EverMadeChange |= F.setSectionPrefix("hot");
+    F.setSectionPrefix("hot");
   } else if (ProfileGuidedSectionPrefix) {
     // The hot attribute overwrites profile count based hotness while profile
     // counts based hotness overwrite the cold attribute.
     // This is a conservative behabvior.
     if (F.hasFnAttribute(Attribute::Hot) ||
         PSI->isFunctionHotInCallGraph(&F, *BFI))
-      EverMadeChange |= F.setSectionPrefix("hot");
+      F.setSectionPrefix("hot");
     // If PSI shows this function is not hot, we will placed the function
     // into unlikely section if (1) PSI shows this is a cold function, or
     // (2) the function has a attribute of cold.
     else if (PSI->isFunctionColdInCallGraph(&F, *BFI) ||
              F.hasFnAttribute(Attribute::Cold))
-      EverMadeChange |= F.setSectionPrefix("unlikely");
+      F.setSectionPrefix("unlikely");
     else if (ProfileUnknownInSpecialSection && PSI->hasPartialSampleProfile() &&
              PSI->isFunctionHotnessUnknown(F))
-      EverMadeChange |= F.setSectionPrefix("unknown");
+      F.setSectionPrefix("unknown");
   }
 
   /// This optimization identifies DIV instructions that can be
diff --git a/llvm/lib/CodeGen/StaticDataAnnotator.cpp b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
index 53a9ab4dbda02..2d9b489a80acb 100644
--- a/llvm/lib/CodeGen/StaticDataAnnotator.cpp
+++ b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
@@ -91,7 +91,8 @@ bool StaticDataAnnotator::runOnModule(Module &M) {
     if (SectionPrefix.empty())
       continue;
 
-    Changed |= GV.setSectionPrefix(SectionPrefix);
+    GV.setSectionPrefix(SectionPrefix);
+    Changed = true;
   }
 
   return Changed;
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 1a7a5c5fbad6b..11d33e262fecb 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -288,22 +288,10 @@ void GlobalObject::setSection(StringRef S) {
   setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
 }
 
-bool GlobalObject::setSectionPrefix(StringRef Prefix) {
-  StringRef ExistingPrefix;
-  if (std::optional<StringRef> MaybePrefix = getSectionPrefix())
-    ExistingPrefix = *MaybePrefix;
-
-  if (ExistingPrefix == Prefix)
-    return false;
-
-  if (Prefix.empty()) {
-    setMetadata(LLVMContext::MD_section_prefix, nullptr);
-    return true;
-  }
+void GlobalObject::setSectionPrefix(StringRef Prefix) {
   MDBuilder MDB(getContext());
   setMetadata(LLVMContext::MD_section_prefix,
               MDB.createGlobalObjectSectionPrefix(Prefix));
-  return true;
 }
 
 std::optional<StringRef> GlobalObject::getSectionPrefix() const {
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index c86092bd51eda..ecb2f2dbc552b 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
@@ -848,12 +848,13 @@ bool MemProfUsePass::annotateGlobalVariables(
     // So we just print out the static data section prefix in LLVM_DEBUG.
     if (Record && Record->AccessCount > 0) {
       ++NumOfMemProfHotGlobalVars;
-      Changed |= GVar.setSectionPrefix("hot");
+      GVar.setSectionPrefix("hot");
+      Changed = true;
       LLVM_DEBUG(dbgs() << "Global variable " << Name
                         << " is annotated as hot\n");
     } else if (DataAccessProf->isKnownColdSymbol(Name)) {
       ++NumOfMemProfColdGlobalVars;
-      Changed |= GVar.setSectionPrefix("unlikely");
+      GVar.setSectionPrefix("unlikely");
       Changed = true;
       LLVM_DEBUG(dbgs() << "Global variable " << Name
                         << " is annotated as unlikely\n");
diff --git a/llvm/unittests/IR/CMakeLists.txt b/llvm/unittests/IR/CMakeLists.txt
index d62ce66ef9d34..8b7bd3997ea27 100644
--- a/llvm/unittests/IR/CMakeLists.txt
+++ b/llvm/unittests/IR/CMakeLists.txt
@@ -28,7 +28,6 @@ add_llvm_unittest(IRTests
   DominatorTreeBatchUpdatesTest.cpp
   DroppedVariableStatsIRTest.cpp
   FunctionTest.cpp
-  GlobalObjectTest.cpp
   PassBuilderCallbacksTest.cpp
   IRBuilderTest.cpp
   InstructionsTest.cpp
diff --git a/llvm/unittests/IR/GlobalObjectTest.cpp b/llvm/unittests/IR/GlobalObjectTest.cpp
deleted file mode 100644
index 0e16d01e759de..0000000000000
--- a/llvm/unittests/IR/GlobalObjectTest.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//===- GlobalObjectTest.cpp - Global object unit tests --------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/IR/GlobalObject.h"
-#include "llvm/AsmParser/Parser.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/SourceMgr.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-using namespace llvm;
-namespace {
-using testing::Eq;
-using testing::Optional;
-using testing::StrEq;
-
-static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
-  SMDiagnostic Err;
-  std::unique_ptr<Module> Mod = parseAssemblyString(IR, Err, C);
-  if (!Mod)
-    Err.print("GlobalObjectTests", errs());
-  return Mod;
-}
-
-static LLVMContext C;
-static std::unique_ptr<Module> M;
-
-class GlobalObjectTest : public testing::Test {
-public:
-  static void SetUpTestSuite() {
-    M = parseIR(C, R"(
-@foo = global i32 3, !section_prefix !0
-@bar = global i32 0
-
-!0 = !{!"section_prefix", !"hot"}
-)");
-  }
-};
-
-TEST_F(GlobalObjectTest, SectionPrefix) {
-  GlobalVariable *Foo = M->getGlobalVariable("foo");
-
-  // Initial section prefix is hot.
-  ASSERT_NE(Foo, nullptr);
-  ASSERT_THAT(Foo->getSectionPrefix(), Optional(StrEq("hot")));
-
-  // Test that set method returns false since existing section prefix is hot.
-  EXPECT_FALSE(Foo->setSectionPrefix("hot"));
-
-  // Set prefix from hot to unlikely.
-  Foo->setSectionPrefix("unlikely");
-  EXPECT_THAT(Foo->getSectionPrefix(), Optional(StrEq("unlikely")));
-
-  // Set prefix to empty is the same as clear.
-  Foo->setSectionPrefix("");
-  // Test that section prefix is cleared.
-  EXPECT_THAT(Foo->getSectionPrefix(), Eq(std::nullopt));
-
-  GlobalVariable *Bar = M->getGlobalVariable("bar");
-
-  // Initial section prefix is empty.
-  ASSERT_NE(Bar, nullptr);
-  ASSERT_THAT(Bar->getSectionPrefix(), Eq(std::nullopt));
-
-  // Test that set method returns false since Bar doesn't have prefix metadata.
-  EXPECT_FALSE(Bar->setSectionPrefix(""));
-
-  // Set from empty to hot.
-  EXPECT_TRUE(Bar->setSectionPrefix("hot"));
-  EXPECT_THAT(Bar->getSectionPrefix(), Optional(StrEq("hot")));
-
-  // Test that set method returns true and section prefix is cleared.
-  EXPECT_TRUE(Bar->setSectionPrefix(""));
-  EXPECT_THAT(Bar->getSectionPrefix(), Eq(std::nullopt));
-}
-} // namespace

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building llvm at step 16 "test-check-lldb-api".

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

Here is the relevant piece of the build log for the reference
Step 16 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
UNSUPPORTED: lldb-api :: functionalities/postmortem/FreeBSDKernel/TestFreeBSDKernelLive.py (568 of 1305)
PASS: lldb-api :: functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py (569 of 1305)
PASS: lldb-api :: functionalities/pointer_num_children/TestPointerNumChildren.py (570 of 1305)
UNSUPPORTED: lldb-api :: functionalities/postmortem/elf-core/expr/TestExpr.py (571 of 1305)
PASS: lldb-api :: functionalities/postmortem/elf-core/TestLinuxCore.py (572 of 1305)
PASS: lldb-api :: functionalities/postmortem/elf-core/gcore/TestGCore.py (573 of 1305)
PASS: lldb-api :: functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py (574 of 1305)
PASS: lldb-api :: functionalities/postmortem/minidump/TestMiniDump.py (575 of 1305)
PASS: lldb-api :: functionalities/postmortem/minidump-new/TestMiniDumpNew.py (576 of 1305)
UNRESOLVED: lldb-api :: functionalities/postmortem/netbsd-core/TestNetBSDCore.py (577 of 1305)
******************** TEST 'lldb-api :: functionalities/postmortem/netbsd-core/TestNetBSDCore.py' FAILED ********************
Script:
--
/usr/bin/python3.12 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --libcxx-include-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1 --libcxx-include-target-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb --compiler /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang --dsymutil /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --lldb-obj-root /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb --lldb-libs-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --cmake-build-type Release --platform-url connect://jetson-agx-2198.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot /mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux --skip-category=lldb-server /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/postmortem/netbsd-core -p TestNetBSDCore.py
--
Exit Code: -6

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 9277bcd1ab83fbfecfaaa5e15f3821808c5a6e38)
  clang revision 9277bcd1ab83fbfecfaaa5e15f3821808c5a6e38
  llvm revision 9277bcd1ab83fbfecfaaa5e15f3821808c5a6e38
Setting up remote platform 'remote-linux'
Connecting to remote platform 'remote-linux' at 'connect://jetson-agx-2198.lab.llvm.org:1234'...
Connected.
Setting remote platform working directory to '/home/ubuntu/lldb-tests'...
Skipping the following test categories: ['lldb-server', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc', 'lldb-dap']

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx arguments
PASS: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_aarch64_single_threaded (TestNetBSDCore.NetBSD1LWPCoreTestCase.test_aarch64_single_threaded)
UNSUPPORTED: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_amd64_single_threaded (TestNetBSDCore.NetBSD1LWPCoreTestCase.test_amd64_single_threaded) (requires X86) 
PASS: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_aarch64_process_signaled (TestNetBSDCore.NetBSD2LWPProcessSigCoreTestCase.test_aarch64_process_signaled)
UNSUPPORTED: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_amd64_process_signaled (TestNetBSDCore.NetBSD2LWPProcessSigCoreTestCase.test_amd64_process_signaled) (requires X86) 
double free or corruption (out)
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 without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  _lldb.cpython-312-x86_64-linux-gnu.so 0x0000737e1e4990b2
1  _lldb.cpython-312-x86_64-linux-gnu.so 0x0000737e1e495faf
2  _lldb.cpython-312-x86_64-linux-gnu.so 0x0000737e1e4960fc
3  libc.so.6                             0x0000737e25645330
4  libc.so.6                             0x0000737e2569eb2c pthread_kill + 284
5  libc.so.6                             0x0000737e2564527e gsignal + 30
6  libc.so.6                             0x0000737e256288ff abort + 223
7  libc.so.6                             0x0000737e256297b6
8  libc.so.6                             0x0000737e256a8ff5
9  libc.so.6                             0x0000737e256ab120

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.

4 participants