Skip to content

Commit b4ca8b1

Browse files
committed
Move HasSignedPersonality to AArch64MachineModuleInfo
1 parent bb04654 commit b4ca8b1

File tree

7 files changed

+72
-18
lines changed

7 files changed

+72
-18
lines changed

llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,10 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
8383
/// extern_weak symbols.
8484
DenseMap<MCSymbol *, const MCExpr *> AuthPtrStubs;
8585

86-
/// HasSignedPersonality is true if the corresponding IR module has the
87-
/// "ptrauth-sign-personality" flag set to 1.
88-
bool HasSignedPersonality = false;
89-
9086
virtual void anchor(); // Out of line virtual method.
9187

9288
public:
93-
MachineModuleInfoELF(const MachineModuleInfo &);
89+
MachineModuleInfoELF(const MachineModuleInfo &) {}
9490

9591
StubValueTy &getGVStubEntry(MCSymbol *Sym) {
9692
assert(Sym && "Key cannot be null");
@@ -109,8 +105,6 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
109105
ExprStubListTy getAuthGVStubList() {
110106
return getSortedExprStubs(AuthPtrStubs);
111107
}
112-
113-
bool hasSignedPersonality() const { return HasSignedPersonality; }
114108
};
115109

116110
/// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation

llvm/lib/CodeGen/MachineModuleInfoImpls.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,3 @@ MachineModuleInfoImpl::ExprStubListTy MachineModuleInfoImpl::getSortedExprStubs(
6161
ExprStubs.clear();
6262
return List;
6363
}
64-
65-
MachineModuleInfoELF::MachineModuleInfoELF(const MachineModuleInfo &MMI) {
66-
const Module *M = MMI.getModule();
67-
const auto *Flag = mdconst::extract_or_null<ConstantInt>(
68-
M->getModuleFlag("ptrauth-sign-personality"));
69-
if (Flag && Flag->getZExtValue() == 1)
70-
HasSignedPersonality = true;
71-
else
72-
HasSignedPersonality = false;
73-
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===--- AArch64MachineModuleInfo.cpp ---------------------------*- C++ -*-===//
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+
//===----------------------------------------------------------------------===//
8+
//
9+
/// \file
10+
/// AArch64 Machine Module Info.
11+
///
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#include "AArch64MachineModuleInfo.h"
16+
#include "llvm/IR/Constants.h"
17+
#include "llvm/IR/Module.h"
18+
19+
namespace llvm {
20+
21+
AArch64MachineModuleInfo::AArch64MachineModuleInfo(const MachineModuleInfo &MMI)
22+
: MachineModuleInfoELF(MMI) {
23+
const Module *M = MMI.getModule();
24+
const auto *Flag = mdconst::extract_or_null<ConstantInt>(
25+
M->getModuleFlag("ptrauth-sign-personality"));
26+
if (Flag && Flag->getZExtValue() == 1)
27+
HasSignedPersonality = true;
28+
else
29+
HasSignedPersonality = false;
30+
}
31+
32+
} // end namespace llvm
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===--- AArch64MachineModuleInfo.h -----------------------------*- C++ -*-===//
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+
//===----------------------------------------------------------------------===//
8+
//
9+
/// \file
10+
/// AArch64 Machine Module Info.
11+
///
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEMODULEINFO_H
16+
#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEMODULEINFO_H
17+
18+
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
19+
20+
namespace llvm {
21+
22+
class AArch64MachineModuleInfo final : public MachineModuleInfoELF {
23+
/// HasSignedPersonality is true if the corresponding IR module has the
24+
/// "ptrauth-sign-personality" flag set to 1.
25+
bool HasSignedPersonality = false;
26+
27+
public:
28+
AArch64MachineModuleInfo(const MachineModuleInfo &);
29+
30+
bool hasSignedPersonality() const { return HasSignedPersonality; }
31+
};
32+
33+
} // end namespace llvm
34+
35+
#endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEMODULEINFO_H

llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AArch64TargetObjectFile.h"
10+
#include "AArch64MachineModuleInfo.h"
1011
#include "AArch64TargetMachine.h"
1112
#include "MCTargetDesc/AArch64MCExpr.h"
1213
#include "MCTargetDesc/AArch64TargetStreamer.h"
@@ -32,7 +33,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
3233
void AArch64_ELFTargetObjectFile::emitPersonalityValueImpl(
3334
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym,
3435
const MachineModuleInfo *MMI) const {
35-
if (!MMI->getObjFileInfo<MachineModuleInfoELF>().hasSignedPersonality()) {
36+
if (!MMI->getObjFileInfo<AArch64MachineModuleInfo>().hasSignedPersonality()) {
3637
TargetLoweringObjectFileELF::emitPersonalityValueImpl(Streamer, DL, Sym,
3738
MMI);
3839
return;

llvm/lib/Target/AArch64/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ add_llvm_target(AArch64CodeGen
6767
AArch64LoadStoreOptimizer.cpp
6868
AArch64LowerHomogeneousPrologEpilog.cpp
6969
AArch64MachineFunctionInfo.cpp
70+
AArch64MachineModuleInfo.cpp
7071
AArch64MachineScheduler.cpp
7172
AArch64MacroFusion.cpp
7273
AArch64MIPeepholeOpt.cpp

llvm/utils/gn/secondary/llvm/lib/Target/AArch64/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static_library("LLVMAArch64CodeGen") {
135135
"AArch64MCInstLower.cpp",
136136
"AArch64MIPeepholeOpt.cpp",
137137
"AArch64MachineFunctionInfo.cpp",
138+
"AArch64MachineModuleInfo.cpp",
138139
"AArch64MachineScheduler.cpp",
139140
"AArch64MacroFusion.cpp",
140141
"AArch64PBQPRegAlloc.cpp",

0 commit comments

Comments
 (0)