Skip to content

Commit 72c47bc

Browse files
committed
[CHERIoT] Use a more general check for xcheriot in the clang driver.
1 parent 8ef788b commit 72c47bc

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include "clang/Driver/CommonArgs.h"
1313
#include "clang/Driver/InputInfo.h"
1414

15-
#include "Arch/Mips.h"
1615
#include "Arch/AArch64.h"
1716
#include "Arch/ARM.h"
17+
#include "Arch/Mips.h"
1818
#include "Arch/RISCV.h"
1919
#include "clang/Driver/Compilation.h"
2020
#include "clang/Driver/Driver.h"
@@ -24,6 +24,7 @@
2424
#include "llvm/Option/ArgList.h"
2525
#include "llvm/Support/Path.h"
2626
#include "llvm/Support/VirtualFileSystem.h"
27+
#include "llvm/TargetParser/RISCVISAInfo.h"
2728

2829
#include <sstream>
2930

@@ -275,13 +276,15 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
275276
}
276277
}
277278

278-
if (Triple.getOS() == llvm::Triple::CheriotRTOS ||
279-
Args.getLastArgValue(options::OPT_mcpu_EQ) == "cheriot" ||
280-
Args.getLastArgValue(options::OPT_mabi_EQ) == "cheriot" ||
281-
Args.getLastArgValue(options::OPT_mabi_EQ) == "cheriot-baremetal")
282-
IsCheriot = true;
283-
else
284-
IsCheriot = false;
279+
IsCheriot = false;
280+
if (Triple.isRISCV()) {
281+
std::string Arch = riscv::getRISCVArch(Args, Triple);
282+
// Canonicalize arch for easier matching
283+
auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
284+
Arch, /*EnableExperimentalExtensions*/ true);
285+
if (!llvm::errorToBool(ISAInfo.takeError()))
286+
IsCheriot = (*ISAInfo)->hasExtension("xcheriot");
287+
}
285288
}
286289

287290
static void

llvm/test/CodeGen/AMDGPU/amdgpu-sw-lower-lds-lower-all.ll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5
22
; RUN: opt < %s -passes=amdgpu-sw-lower-lds -S -amdgpu-asan-instrument-lds=false -mtriple=amdgcn-amd-amdhsa | FileCheck %s
3-
; XFAIL: *
3+
4+
; CHERIOT-FIXME: Disabled due to non-deterministic failures.
5+
; UNSUPPORTED: true
6+
47
; Test to check if static LDS accesses in kernels without sanitize_address attribute are lowered if
58
; other kernels in module have sanitize_address attribute.
69
@lds_1 = internal addrspace(3) global [1 x i8] poison, align 4

0 commit comments

Comments
 (0)