Skip to content

Commit 5103e64

Browse files
committed
[CHERI] Disable GlobalMerge for for RISCV whenever CHERI is enabled in any form.
1 parent aa5f9b7 commit 5103e64

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

llvm/include/llvm/Target/TargetMachine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ class TargetMachine {
203203
return DL.getPointerSize(DL.getAllocaAddrSpace());
204204
}
205205

206+
bool hasCheriCapabilities() const {
207+
return DL.hasCheriCapabilities();
208+
}
209+
206210
/// Reset the target options based on the function's attributes.
207211
// FIXME: Remove TargetOptions that affect per-function code generation
208212
// from TargetMachine.

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ bool RISCVPassConfig::addPreISel() {
510510
addPass(createBarrierNoopPass());
511511
}
512512

513-
bool isCheriot =
514-
TM->getTargetTriple().getSubArch() == Triple::RISCV32SubArch_cheriot_v1;
515-
if ((TM->getOptLevel() != CodeGenOptLevel::None && !isCheriot &&
513+
// XXX: GlobalMerge is undesirable on CHERI, as it makes the bounds on globals
514+
// excessively loose.
515+
if ((TM->getOptLevel() != CodeGenOptLevel::None && !TM->hasCheriCapabilities() &&
516516
EnableGlobalMerge == cl::BOU_UNSET) ||
517517
EnableGlobalMerge == cl::BOU_TRUE) {
518518
// FIXME: Like AArch64, we disable extern global merging by default due to

0 commit comments

Comments
 (0)