Skip to content

[KeyInstr] Remove LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS CMake flag #152735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ llvm_canonicalize_cmake_booleans(
PPC_LINUX_DEFAULT_IEEELONGDOUBLE
LLVM_TOOL_LLVM_DRIVER_BUILD
LLVM_INCLUDE_SPIRV_TOOLS_TESTS
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS
)

# Run tests requiring Z3 headers only if LLVM was built with Z3
Expand Down
2 changes: 0 additions & 2 deletions clang/test/DebugInfo/KeyInstructions/lit.local.cfg

This file was deleted.

1 change: 0 additions & 1 deletion clang/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@
config.substitutions.append(("%llvm-version-major", "@LLVM_VERSION_MAJOR@"))
config.has_key_instructions = @LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS@

import lit.llvm
lit.llvm.initialize(lit_config, config)
Expand Down
3 changes: 0 additions & 3 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,6 @@ set(LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
"Enhance Debugify's line number coverage tracking; enabling this is ABI-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
set_property(CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE COVERAGE_AND_ORIGIN)

option(LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS
"Add additional fields to DILocations to support Key Instructions" ON)

set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
if (MINGW)
# Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix
Expand Down
4 changes: 0 additions & 4 deletions llvm/cmake/modules/HandleLLVMOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ endif()
# LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE (non-cached) is expected to be
# 1 or 0 here, assuming referenced in #cmakedefine01.

if(LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS)
add_compile_definitions(EXPERIMENTAL_KEY_INSTRUCTIONS)
endif()

if( LLVM_REVERSE_ITERATION )
set( LLVM_ENABLE_REVERSE_ITERATION 1 )
endif()
Expand Down
10 changes: 0 additions & 10 deletions llvm/include/llvm/IR/DebugInfoMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2506,10 +2506,8 @@ class DISubprogram : public DILocalScope {
class DILocation : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
uint64_t AtomGroup : 61;
uint64_t AtomRank : 3;
#endif

DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, uint64_t AtomGroup, uint8_t AtomRank,
Expand Down Expand Up @@ -2540,18 +2538,10 @@ class DILocation : public MDNode {

public:
uint64_t getAtomGroup() const {
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
return AtomGroup;
#else
return 0;
#endif
}
uint8_t getAtomRank() const {
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
return AtomRank;
#else
return 0;
#endif
}

const DILocation *getWithoutAtom() const {
Expand Down
10 changes: 2 additions & 8 deletions llvm/lib/IR/DebugInfoMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ DebugVariable::DebugVariable(const DbgVariableRecord *DVR)
DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, uint64_t AtomGroup, uint8_t AtomRank,
ArrayRef<Metadata *> MDs, bool ImplicitCode)
: MDNode(C, DILocationKind, Storage, MDs)
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
,
AtomGroup(AtomGroup), AtomRank(AtomRank)
#endif
{
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
: MDNode(C, DILocationKind, Storage, MDs), AtomGroup(AtomGroup),
AtomRank(AtomRank) {
assert(AtomRank <= 7 && "AtomRank number should fit in 3 bits");
#endif
if (AtomGroup)
C.updateDILocationAtomGroupWaterline(AtomGroup + 1);

Expand Down
19 changes: 3 additions & 16 deletions llvm/lib/IR/LLVMContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,22 @@ template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
template <> struct MDNodeKeyImpl<DILocation> {
Metadata *Scope;
Metadata *InlinedAt;
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
uint64_t AtomGroup : 61;
uint64_t AtomRank : 3;
#endif
unsigned Line;
uint16_t Column;
bool ImplicitCode;

MDNodeKeyImpl(unsigned Line, uint16_t Column, Metadata *Scope,
Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup,
uint8_t AtomRank)
: Scope(Scope), InlinedAt(InlinedAt),
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
AtomGroup(AtomGroup), AtomRank(AtomRank),
#endif
Line(Line), Column(Column), ImplicitCode(ImplicitCode) {
}
: Scope(Scope), InlinedAt(InlinedAt), AtomGroup(AtomGroup),
AtomRank(AtomRank), Line(Line), Column(Column),
ImplicitCode(ImplicitCode) {}

MDNodeKeyImpl(const DILocation *L)
: Scope(L->getRawScope()), InlinedAt(L->getRawInlinedAt()),
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
AtomGroup(L->getAtomGroup()), AtomRank(L->getAtomRank()),
#endif
Line(L->getLine()), Column(L->getColumn()),
ImplicitCode(L->isImplicitCode()) {
}
Expand All @@ -343,16 +336,11 @@ template <> struct MDNodeKeyImpl<DILocation> {
return Line == RHS->getLine() && Column == RHS->getColumn() &&
Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt() &&
ImplicitCode == RHS->isImplicitCode()
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
&& AtomGroup == RHS->getAtomGroup() &&
AtomRank == RHS->getAtomRank();
#else
;
#endif
}

unsigned getHashValue() const {
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
// Hashing AtomGroup and AtomRank substantially impacts performance whether
// Key Instructions is enabled or not. We can't detect whether it's enabled
// here cheaply; avoiding hashing zero values is a good approximation. This
Expand All @@ -363,7 +351,6 @@ template <> struct MDNodeKeyImpl<DILocation> {
if (AtomGroup || AtomRank)
return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode,
AtomGroup, (uint8_t)AtomRank);
#endif
return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode);
}
};
Expand Down
1 change: 0 additions & 1 deletion llvm/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ llvm_canonicalize_cmake_booleans(
LLVM_INCLUDE_SPIRV_TOOLS_TESTS
LLVM_APPEND_VC_REV
LLVM_HAS_LOGF128
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS
)

configure_lit_site_cfg(
Expand Down
5 changes: 1 addition & 4 deletions llvm/test/DebugInfo/KeyInstructions/debugify.ll
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
; RUN: opt -passes=debugify --debugify-atoms -S -o - < %s \
; RUN: | FileCheck %s

;; Mirrors llvm/test/DebugInfo/debugify.ll. Split out here because the
;; test is only supported if LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS is enabled
;; (which is a condition for running this test directory). Once the conditional
;; compilation of the feature is removed this can be merged into the original.
;; Mirrors llvm/test/DebugInfo/debugify.ll

; CHECK-LABEL: define void @foo
define void @foo() {
Expand Down
2 changes: 0 additions & 2 deletions llvm/test/DebugInfo/KeyInstructions/lit.local.cfg

This file was deleted.

1 change: 0 additions & 1 deletion llvm/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@
config.have_vc_rev = @LLVM_APPEND_VC_REV@
config.force_vc_rev = "@LLVM_FORCE_VC_REVISION@"
config.has_logf128 = @LLVM_HAS_LOGF128@
config.has_key_instructions = @LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS@

import lit.llvm
lit.llvm.initialize(lit_config, config)
Expand Down
8 changes: 0 additions & 8 deletions llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ TEST(BasicBlockDbgInfoTest, DropSourceAtomOnSplit) {
ASSERT_TRUE(After);
const DebugLoc &OrigTerminatorDL = After->getTerminator()->getDebugLoc();
ASSERT_TRUE(OrigTerminatorDL);
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
EXPECT_EQ(OrigTerminatorDL->getAtomGroup(), 1u);
#else
EXPECT_EQ(OrigTerminatorDL->getAtomGroup(), 0u);
#endif
}

// Test splitBasicBlock.
Expand All @@ -204,11 +200,7 @@ TEST(BasicBlockDbgInfoTest, DropSourceAtomOnSplit) {

const DebugLoc &OrigTerminatorDL = After->getTerminator()->getDebugLoc();
ASSERT_TRUE(OrigTerminatorDL);
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
EXPECT_EQ(OrigTerminatorDL->getAtomGroup(), 1u);
#else
EXPECT_EQ(OrigTerminatorDL->getAtomGroup(), 0u);
#endif

BasicBlock *Before = After->getSinglePredecessor();
ASSERT_TRUE(Before);
Expand Down
16 changes: 1 addition & 15 deletions llvm/unittests/IR/MetadataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,17 +1470,10 @@ TEST_F(DILocationTest, Merge) {
PickMergedSourceLocations = false;
}

#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
#define EXPECT_ATOM(Loc, Group, Rank) \
EXPECT_EQ(Group, M->getAtomGroup()); \
EXPECT_EQ(Rank, M->getAtomRank());
#else
#define EXPECT_ATOM(Loc, Group, Rank) \
EXPECT_EQ(0u, M->getAtomGroup()); \
EXPECT_EQ(0u, M->getAtomRank()); \
(void)Group; \
(void)Rank;
#endif

// Identical, including source atom numbers.
{
auto *A = DILocation::get(Context, 2, 7, N, nullptr, false, /*AtomGroup*/ 1,
Expand Down Expand Up @@ -1753,15 +1746,8 @@ TEST_F(DILocationTest, KeyInstructions) {
EXPECT_EQ(Context.pImpl->NextAtomGroup, 1u);
DILocation *A1 =
DILocation::get(Context, 1, 0, getSubprogram(), nullptr, false, 1, 2);
// The group is only applied to the DILocation if we've built LLVM with
// EXPERIMENTAL_KEY_INSTRUCTIONS.
#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
EXPECT_EQ(A1->getAtomGroup(), 1u);
EXPECT_EQ(A1->getAtomRank(), 2u);
#else
EXPECT_EQ(A1->getAtomGroup(), 0u);
EXPECT_EQ(A1->getAtomRank(), 0u);
#endif

// Group number 1 has been "used" so next available is 2.
EXPECT_EQ(Context.pImpl->NextAtomGroup, 2u);
Expand Down
4 changes: 0 additions & 4 deletions llvm/unittests/Transforms/Utils/CloningTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,13 +1203,9 @@ TEST_F(CloneInstruction, cloneKeyInstructions) {

ASSERT_FALSE(verifyModule(*M, &errs()));

#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS
#define EXPECT_ATOM(Inst, G) \
EXPECT_TRUE(Inst->getDebugLoc()); \
EXPECT_EQ(Inst->getDebugLoc()->getAtomGroup(), uint64_t(G));
#else
#define EXPECT_ATOM(Inst, G) (void)Inst;
#endif

Function *F = M->getFunction("test");
BasicBlock *BB = &*F->begin();
Expand Down
1 change: 0 additions & 1 deletion llvm/utils/gn/secondary/clang/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ write_lit_config("lit_site_cfg") {
"CLANG_VENDOR_UTI=org.llvm.clang",
"ENABLE_BACKTRACES=1",
"ENABLE_SHARED=0",
"LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS=0",
"LLVM_EXTERNAL_LIT=",
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_INCLUDE_SPIRV_TOOLS_TESTS=0",
Expand Down
1 change: 0 additions & 1 deletion llvm/utils/gn/secondary/llvm/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ write_lit_config("lit_site_cfg") {
"LLVM_ENABLE_FFI=0",
"LLVM_ENABLE_HTTPLIB=0",
"LLVM_ENABLE_PROFCHECK=0",
"LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS=0",
"LLVM_FORCE_VC_REVISION=",
"LLVM_HAS_LOGF128=0",
"LLVM_HAVE_OPT_VIEWER_MODULES=0",
Expand Down
1 change: 0 additions & 1 deletion utils/bazel/llvm-project-overlay/llvm/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ llvm_config_defines = os_defines + builtin_thread_pointer + select({
"LLVM_VERSION_PATCH={}".format(LLVM_VERSION_PATCH),
r'LLVM_VERSION_STRING=\"{}\"'.format(PACKAGE_VERSION),
# Set globally in HandleLLVMOptions.cmake
"EXPERIMENTAL_KEY_INSTRUCTIONS",
# These shouldn't be needed by the C++11 standard, but are for some
# platforms (e.g. glibc < 2.18. See
# https://sourceware.org/bugzilla/show_bug.cgi?id=15366). These are also
Expand Down
Loading