[MLIR] Prevent invalid IR from being passed outside of RemoveDeadValues (#121079)
[llvm-project.git] / llvm / unittests / ExecutionEngine / JITLink / MachOLinkGraphTests.cpp
blob173ec14fe260fafb259f86a5ef3b882270bbc66e
1 //===------ MachOLinkGraphTests.cpp - Unit tests for MachO LinkGraphs -----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "JITLinkTestUtils.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
13 #include "llvm/ExecutionEngine/JITLink/MachO.h"
14 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
16 #include "llvm/Testing/Support/Error.h"
17 #include "gtest/gtest.h"
19 using namespace llvm;
20 using namespace llvm::jitlink;
22 TEST(MachOLinkGraphTest, GetStandardSections) {
23 // Check that LinkGraph construction works as expected.
24 LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
25 Triple("arm64-apple-darwin"), SubtargetFeatures(),
26 getGenericEdgeKindName);
28 auto &Data = getMachODefaultRWDataSection(G);
29 EXPECT_TRUE(Data.empty());
30 EXPECT_EQ(Data.getName(), orc::MachODataDataSectionName);
31 EXPECT_EQ(Data.getMemProt(), orc::MemProt::Read | orc::MemProt::Write);
33 auto &Text = getMachODefaultTextSection(G);
34 EXPECT_TRUE(Text.empty());
35 EXPECT_EQ(Text.getName(), orc::MachOTextTextSectionName);
36 EXPECT_EQ(Text.getMemProt(), orc::MemProt::Read | orc::MemProt::Exec);