Skip to content

Commit 44c01c2

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

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm/include/llvm/Target/TargetMachine.h

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

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

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,10 @@ 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 &&
516-
EnableGlobalMerge == cl::BOU_UNSET) ||
513+
// XXX: GlobalMerge is undesirable on CHERI, as it makes the bounds on globals
514+
// excessively loose.
515+
if ((TM->getOptLevel() != CodeGenOptLevel::None &&
516+
!TM->hasCheriCapabilities() && EnableGlobalMerge == cl::BOU_UNSET) ||
517517
EnableGlobalMerge == cl::BOU_TRUE) {
518518
// FIXME: Like AArch64, we disable extern global merging by default due to
519519
// concerns it might regress some workloads. Unlike AArch64, we don't

0 commit comments

Comments
 (0)