Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions llvm/test/tools/llvm-snippy/call-graph-function-number-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# RUN: not llvm-snippy %s |& FileCheck %s

# CHECK: error: Option "function-number" cannot be used together with "call-graph"

include:
- Inputs/sections.yaml

options:
mtriple: riscv64
mattr: +m
function-number: 37
num-instrs: 100
dump-mf: true

histogram:
- [ADD, 1.0]
- [ADDI, 1.0]
- [SUB, 1.0]
- [MUL, 1.0]

call-graph:
entry-point: SnippyFunction
function-list:
- name: SnippyFunction
callees:
- fun1
- fun2
- fun3
- name: fun1
callees:
- fun2
- name: fun2
callees:
- fun3
- name: fun3
external: true
19 changes: 17 additions & 2 deletions llvm/test/tools/llvm-snippy/calls/calls-randomize-ra-for-func.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# COM: This test checks that option randomize-ra can be specified for specific
# functions in call-graph.

# RUN: llvm-snippy %S/calls-randomize-ra.yaml %s -redefine-ra=reg::X7 \
# RUN: -model-plugin None &> %t.mf
# RUN: llvm-snippy %s -redefine-ra=reg::X7 -model-plugin None &> %t.mf


# COM: Here we check that there are exactly two different return addresses (for
Expand Down Expand Up @@ -36,6 +35,22 @@
# RUN: | not grep -n -v 'x7 = '


options:
mtriple: riscv64
num-instrs: 1000
num-instr-ancil: 50
verify-mi: on
dump-mf: on

include:
- Inputs/sections-with-stack.yaml

histogram:
- [ADD, 1.0]
- [ADDI, 1.0]
- [SUB, 1.0]
- [JAL, 1.0]

call-graph:
entry-point: fun4
function-list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ options:
num-instrs: 1000
honor-target-abi: on
mattr: +zcmp
function-number: 2
redefine-sp: any-not-SP

include:
Expand Down
2 changes: 0 additions & 2 deletions llvm/test/tools/llvm-snippy/liveins-calls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ options:
mtriple: riscv64
num-instrs: 200
init-regs-in-elf: true
function-number: 20
function-layers: 5
verify-mi: true

sections:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ struct CallGraphLayout {

unsigned getDepth() const { return MaxLayers; }
};

bool isFunctionLayersSpecified();
bool isFunctionNumberSpecified();

} // namespace snippy

LLVM_SNIPPY_YAML_DECLARE_MAPPING_TRAITS(snippy::CallGraphLayout);
Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/llvm-snippy/lib/Config/CallGraphLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ static snippy::opt<bool>
cl::desc("return address register randomization"),
cl::Hidden, cl::cat(Options), cl::init(false));

bool isFunctionLayersSpecified() { return FunctionLayers.isSpecified(); }

bool isFunctionNumberSpecified() { return FunctionNumberOpt.isSpecified(); }

CallGraphLayout::CallGraphLayout()
: MaxLayers(FunctionLayers), FunctionNumber(FunctionNumberOpt),
InstrNumAncil(NumInstrAncil), RandomizeRA(RandomizeRAOpt) {}
Expand Down
11 changes: 11 additions & 0 deletions llvm/tools/llvm-snippy/lib/Config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,11 +1418,22 @@ static std::string checkSMCConfig(ConfigIOContext &ConfigIOCtx, Config &Info) {
}

std::string yaml::MappingTraits<Config>::validate(yaml::IO &Io, Config &Info) {
if (std::holds_alternative<FunctionDescs>(Info.PassCfg.CGLayout)) {
if (snippy::isFunctionNumberSpecified())
return "Option \"function-number\" cannot be used together with "
"\"call-graph\"";

if (snippy::isFunctionLayersSpecified())
return "Option \"function-layers\" cannot be used together with "
"\"call-graph\"";
}

if (Info.PassCfg.CodeLayout && !Info.PassCfg.Branches.unaligned())
return Twine("Code layout feature is only supported with branches "
"alignment set to ")
.concat(Twine(Branchegram::Unaligned))
.str();

void *Ctx = Io.getContext();
assert(Ctx && "To parse or output Config provide ConfigIOContext as "
"context for yaml::IO");
Expand Down
Loading