[XRay] Rename XRayOmitFunctionIndex to XRayFunctionIndex

Apply my post-commit comment on D81995. The negative name misguided commit
d8a8e5d624 (`[clang][cli] Remove marshalling from
Opt{In,Out}FFlag`) to:

* accidentally flip the option to not emit the xray_fn_idx section.
* change -fno-xray-function-index (instead of -fxray-function-index) to emit xray_fn_idx

This patch renames XRayOmitFunctionIndex and makes -fxray-function-index emit
xray_fn_idx, but the default remains -fno-xray-function-index .
This commit is contained in:
Fangrui Song
2023-06-11 15:27:22 -07:00
parent df357a71dd
commit 849f1dd15e
12 changed files with 35 additions and 34 deletions

View File

@@ -130,8 +130,8 @@ CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
///< Set when -fxray-ignore-loops is enabled.
CODEGENOPT(XRayIgnoreLoops , 1, 0)
///< Set with -fno-xray-function-index to omit the index section.
CODEGENOPT(XRayOmitFunctionIndex , 1, 0)
///< Emit the XRay function index section.
CODEGENOPT(XRayFunctionIndex , 1, 1)
///< Set the minimum number of instructions in a function to determine selective

View File

@@ -2216,10 +2216,10 @@ defm xray_ignore_loops : BoolFOption<"xray-ignore-loops",
NegFlag<SetFalse>>;
defm xray_function_index : BoolFOption<"xray-function-index",
CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
NegFlag<SetFalse, [CC1Option], "Omit function index section at the"
" expense of single-function patching performance">,
PosFlag<SetTrue>>;
CodeGenOpts<"XRayFunctionIndex">, DefaultFalse,
PosFlag<SetTrue, [CC1Option]>,
NegFlag<SetFalse, [], "Omit function index section at the"
" expense of single-function patching performance">>;
def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>,
Flags<[CC1Option]>,

View File

@@ -429,7 +429,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
Options.EnableAIXExtendedAltivecABI = LangOpts.EnableAIXExtendedAltivecABI;
Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
Options.XRayFunctionIndex = CodeGenOpts.XRayFunctionIndex;
Options.LoopAlignment = CodeGenOpts.LoopAlignment;
Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;
Options.ObjectFilenameForDebug = CodeGenOpts.ObjectFilenameForDebug;

View File

@@ -178,8 +178,8 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
options::OPT_fno_xray_always_emit_typedevents);
Args.addOptInFlag(CmdArgs, options::OPT_fxray_ignore_loops,
options::OPT_fno_xray_ignore_loops);
Args.addOptOutFlag(CmdArgs, options::OPT_fxray_function_index,
options::OPT_fno_xray_function_index);
Args.addOptInFlag(CmdArgs, options::OPT_fxray_function_index,
options::OPT_fno_xray_function_index);
if (const Arg *A =
Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {

View File

@@ -0,0 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-index %s -o - | FileCheck %s
// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 %s -o - | FileCheck %s --check-prefix=NO
// CHECK: .section xray_fn_idx,"awo",@progbits,foo
// NO-NOT: .section xray_fn_idx
void foo(void) {}

View File

@@ -1,12 +0,0 @@
// This test ensures that when we invoke the clang compiler, that the -cc1
// options respect the -fno-xray-function-index flag we provide in the
// invocation. The default should be to *include* the function index.
//
// RUN: %clang -### -fxray-instrument -target x86_64 -c %s 2>&1 | FileCheck %s
// RUN: %clang -### -fxray-instrument -target x86_64 -fxray-function-index -c %s 2>&1 | FileCheck %s
// CHECK-NOT: -fno-xray-function-index
// RUN: %clang -### -fxray-instrument -target x86_64 -fno-xray-function-index -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLED
// CHECK-DISABLED: -fno-xray-function-index

View File

@@ -0,0 +1,5 @@
// RUN: %clang -### -c --target=x86_64 -fxray-instrument -fxray-function-index %s 2>&1 | FileCheck %s
// RUN: %clang -### -c --target=x86_64 -fxray-instrument %s 2>&1 | FileCheck %s --check-prefix=DISABLED
// CHECK: "-fxray-function-index"
// DISABLED-NOT: "-fxray-function-index"

View File

@@ -136,7 +136,7 @@ std::optional<bool> getExplicitValueTrackingVariableLocations();
bool getForceDwarfFrameSection();
bool getXRayOmitFunctionIndex();
bool getXRayFunctionIndex();
bool getDebugStrictDwarf();

View File

@@ -140,7 +140,7 @@ namespace llvm {
SupportsDefaultOutlining(false), EmitAddrsig(false),
EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
EnableDebugEntryValues(false), ValueTrackingVariableLocations(false),
ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
ForceDwarfFrameSection(false), XRayFunctionIndex(true),
DebugStrictDwarf(false), Hotpatch(false),
PPCGenScalarMASSEntries(false), JMCInstrument(false),
EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
@@ -334,7 +334,7 @@ namespace llvm {
unsigned ForceDwarfFrameSection : 1;
/// Emit XRay Function Index section
unsigned XRayOmitFunctionIndex : 1;
unsigned XRayFunctionIndex : 1;
/// When set to true, don't use DWARF extensions in later DWARF versions.
/// By default, it is set to false.

View File

@@ -4011,14 +4011,14 @@ void AsmPrinter::emitXRayTable() {
Flags, 0, GroupName, F.hasComdat(),
MCSection::NonUniqueID, LinkedToSym);
if (!TM.Options.XRayOmitFunctionIndex)
if (TM.Options.XRayFunctionIndex)
FnSledIndex = OutContext.getELFSection(
"xray_fn_idx", ELF::SHT_PROGBITS, Flags | ELF::SHF_WRITE, 0,
GroupName, F.hasComdat(), MCSection::NonUniqueID, LinkedToSym);
} else if (MF->getSubtarget().getTargetTriple().isOSBinFormatMachO()) {
InstMap = OutContext.getMachOSection("__DATA", "xray_instr_map", 0,
SectionKind::getReadOnlyWithRel());
if (!TM.Options.XRayOmitFunctionIndex)
if (TM.Options.XRayFunctionIndex)
FnSledIndex = OutContext.getMachOSection(
"__DATA", "xray_fn_idx", 0, SectionKind::getReadOnlyWithRel());
} else {

View File

@@ -99,7 +99,7 @@ CGOPT(bool, EmitCallSiteInfo)
CGOPT(bool, EnableMachineFunctionSplitter)
CGOPT(bool, EnableDebugEntryValues)
CGOPT(bool, ForceDwarfFrameSection)
CGOPT(bool, XRayOmitFunctionIndex)
CGOPT(bool, XRayFunctionIndex)
CGOPT(bool, DebugStrictDwarf)
CGOPT(unsigned, AlignLoops)
CGOPT(bool, JMCInstrument)
@@ -461,10 +461,10 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
cl::desc("Always emit a debug frame section."), cl::init(false));
CGBINDOPT(ForceDwarfFrameSection);
static cl::opt<bool> XRayOmitFunctionIndex(
"no-xray-index", cl::desc("Don't emit xray_fn_idx section"),
cl::init(false));
CGBINDOPT(XRayOmitFunctionIndex);
static cl::opt<bool> XRayFunctionIndex("xray-function-index",
cl::desc("Emit xray_fn_idx section"),
cl::init(true));
CGBINDOPT(XRayFunctionIndex);
static cl::opt<bool> DebugStrictDwarf(
"strict-dwarf", cl::desc("use strict dwarf"), cl::init(false));
@@ -559,7 +559,7 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
Options.EmitCallSiteInfo = getEmitCallSiteInfo();
Options.EnableDebugEntryValues = getEnableDebugEntryValues();
Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
Options.XRayFunctionIndex = getXRayFunctionIndex();
Options.DebugStrictDwarf = getDebugStrictDwarf();
Options.LoopAlignment = getAlignLoops();
Options.JMCInstrument = getJMCInstrument();

View File

@@ -1,5 +1,5 @@
; RUN: llc -no-xray-index -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,CHECK-LINUX
; RUN: llc -no-xray-index -mtriple=aarch64-apple-darwin < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MACOS
; RUN: llc -mtriple=aarch64-unknown-linux-gnu -xray-function-index=0 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-LINUX
; RUN: llc -mtriple=aarch64-apple-darwin -xray-function-index=0 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MACOS
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK-LABEL: Lxray_sled_0: