Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

91 lines
3.0 KiB
C++

//===-------- X86_64Tests.cpp - Unit tests for the AArch64 backend --------===//
//
// 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/BinaryFormat/ELF.h>
#include <llvm/ExecutionEngine/JITLink/x86_64.h>
#include "gtest/gtest.h"
using namespace llvm;
using namespace llvm::jitlink;
using namespace llvm::jitlink::x86_64;
TEST(X86_64, EmptyLinkGraph) {
LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
Triple("x86_64-apple-darwin"), SubtargetFeatures(),
getEdgeKindName);
EXPECT_EQ(G.getName(), "foo");
EXPECT_EQ(G.getTargetTriple().str(), "x86_64-apple-darwin");
EXPECT_EQ(G.getPointerSize(), 8U);
EXPECT_EQ(G.getEndianness(), llvm::endianness::little);
EXPECT_TRUE(G.external_symbols().empty());
EXPECT_TRUE(G.absolute_symbols().empty());
EXPECT_TRUE(G.defined_symbols().empty());
EXPECT_TRUE(G.blocks().empty());
}
TEST(X86_64, GOTAndStubs) {
LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
Triple("x86_64-apple-darwin"), SubtargetFeatures(),
getEdgeKindName);
auto &External = G.addExternalSymbol("external", 0, false);
// First table accesses. We expect the graph to be empty:
EXPECT_EQ(G.findSectionByName(GOTTableManager::getSectionName()), nullptr);
EXPECT_EQ(G.findSectionByName(PLTTableManager::getSectionName()), nullptr);
{
// Create first GOT and PLT table managers and request a PLT stub. This
// should force creation of both a PLT stub and GOT entry.
GOTTableManager GOT(G);
PLTTableManager PLT(G, GOT);
PLT.getEntryForTarget(G, External);
}
auto *GOTSec = G.findSectionByName(GOTTableManager::getSectionName());
EXPECT_NE(GOTSec, nullptr);
if (GOTSec) {
// Expect one entry in the GOT now.
EXPECT_EQ(GOTSec->symbols_size(), 1U);
EXPECT_EQ(GOTSec->blocks_size(), 1U);
}
auto *PLTSec = G.findSectionByName(PLTTableManager::getSectionName());
EXPECT_NE(PLTSec, nullptr);
if (PLTSec) {
// Expect one entry in the PLT.
EXPECT_EQ(PLTSec->symbols_size(), 1U);
EXPECT_EQ(PLTSec->blocks_size(), 1U);
}
{
// Create second GOT and PLT table managers and request a PLT stub. This
// should force creation of both a PLT stub and GOT entry.
GOTTableManager GOT(G);
PLTTableManager PLT(G, GOT);
PLT.getEntryForTarget(G, External);
}
EXPECT_EQ(G.findSectionByName(GOTTableManager::getSectionName()), GOTSec);
if (GOTSec) {
// Expect the same one entry in the GOT.
EXPECT_EQ(GOTSec->symbols_size(), 1U);
EXPECT_EQ(GOTSec->blocks_size(), 1U);
}
EXPECT_EQ(G.findSectionByName(PLTTableManager::getSectionName()), PLTSec);
if (PLTSec) {
// Expect the same one entry in the GOT.
EXPECT_EQ(PLTSec->symbols_size(), 1U);
EXPECT_EQ(PLTSec->blocks_size(), 1U);
}
}