Skip to content

Commit 72d3afd

Browse files
authored
Remove compiler warnings (#153)
1 parent 9a50452 commit 72d3afd

21 files changed

+205
-199
lines changed

lib/passes/TypeARTConfiguration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CommandLineOptions;
3030

3131
namespace env {
3232
class EnvironmentFlagsOptions;
33-
}
33+
} // namespace env
3434

3535
class TypeARTConfiguration final : public Configuration {
3636
private:

lib/passes/TypeARTPass.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "instrumentation/TypeARTFunctions.h"
2525
#include "support/Logger.h"
2626
#include "support/Table.h"
27+
#include "support/Util.h"
2728
#include "typegen/TypeGenerator.h"
2829

2930
#include "llvm/ADT/DenseMap.h"
@@ -126,11 +127,11 @@ class TypeArtPass : public llvm::PassInfoMixin<TypeArtPass> {
126127
? config::TypeARTConfigInit{config_file_path.value()}
127128
: config::TypeARTConfigInit{{}, config::TypeARTConfigInit::FileConfigurationMode::Empty};
128129

129-
auto typeart_config = [&](const auto& init) {
130-
if (init.mode == config::TypeARTConfigInit::FileConfigurationMode::Empty) {
130+
auto typeart_config = [&](const auto& init_value) {
131+
if (init_value.mode == config::TypeARTConfigInit::FileConfigurationMode::Empty) {
131132
return config::make_typeart_configuration_from_opts(pass_opts.value_or(config::TypeARTConfigOptions{}));
132133
}
133-
return config::make_typeart_configuration(init);
134+
return config::make_typeart_configuration(init_value);
134135
}(init);
135136

136137
if (typeart_config) {
@@ -250,8 +251,8 @@ class TypeArtPass : public llvm::PassInfoMixin<TypeArtPass> {
250251
};
251252

252253
Table stats("TypeArtPass");
253-
stats.wrap_header = true;
254-
stats.title += get_ta_mode();
254+
stats.wrap_header_ = true;
255+
stats.title_ += get_ta_mode();
255256
stats.put(Row::make("Malloc", NumInstrumentedMallocs.getValue()));
256257
stats.put(Row::make("Free", NumInstrumentedFrees.getValue()));
257258
stats.put(Row::make("Alloca", NumInstrumentedAlloca.getValue()));
@@ -292,7 +293,7 @@ class TypeArtPass : public llvm::PassInfoMixin<TypeArtPass> {
292293
bool runOnFunc(llvm::Function& f) {
293294
using namespace typeart;
294295

295-
if (f.isDeclaration() || f.getName().startswith("__typeart")) {
296+
if (f.isDeclaration() || util::starts_with_any_of(f.getName(), "__typeart")) {
296297
return false;
297298
}
298299

lib/passes/analysis/MemInstFinder.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,28 @@ static std::unique_ptr<typeart::filter::Filter> make_filter(const MemInstFinderC
117117
CallFilter::CallFilter(const MemInstFinderConfig& config) : fImpl{detail::make_filter(config)} {
118118
}
119119

120-
bool CallFilter::operator()(AllocaInst* in) {
121-
LOG_DEBUG("Analyzing value: " << util::dump(*in));
120+
bool CallFilter::operator()(AllocaInst* allocation) {
121+
LOG_DEBUG("Analyzing value: " << util::dump(*allocation));
122122
fImpl->setMode(/*search mallocs = */ false);
123-
fImpl->setStartingFunction(in->getParent()->getParent());
124-
const auto filter_ = fImpl->filter(in);
123+
fImpl->setStartingFunction(allocation->getParent()->getParent());
124+
const auto filter_ = fImpl->filter(allocation);
125125
if (filter_) {
126-
LOG_DEBUG("Filtering value: " << util::dump(*in) << "\n");
126+
LOG_DEBUG("Filtering value: " << util::dump(*allocation) << "\n");
127127
} else {
128-
LOG_DEBUG("Keeping value: " << util::dump(*in) << "\n");
128+
LOG_DEBUG("Keeping value: " << util::dump(*allocation) << "\n");
129129
}
130130
return filter_;
131131
}
132132

133-
bool CallFilter::operator()(GlobalValue* g) {
134-
LOG_DEBUG("Analyzing value: " << util::dump(*g));
133+
bool CallFilter::operator()(GlobalValue* global_value) {
134+
LOG_DEBUG("Analyzing value: " << util::dump(*global_value));
135135
fImpl->setMode(/*search mallocs = */ false);
136136
fImpl->setStartingFunction(nullptr);
137-
const auto filter_ = fImpl->filter(g);
137+
const auto filter_ = fImpl->filter(global_value);
138138
if (filter_) {
139-
LOG_DEBUG("Filtering value: " << util::dump(*g) << "\n");
139+
LOG_DEBUG("Filtering value: " << util::dump(*global_value) << "\n");
140140
} else {
141-
LOG_DEBUG("Keeping value: " << util::dump(*g) << "\n");
141+
LOG_DEBUG("Keeping value: " << util::dump(*global_value) << "\n");
142142
}
143143
return filter_;
144144
}
@@ -410,9 +410,9 @@ void MemInstFinderPass::printStats(llvm::raw_ostream& out) const {
410410
(double(NumFilteredGlobals) / std::max(1.0, double(NumDetectedGlobals))) * 100.0;
411411

412412
Table stats("MemInstFinderPass");
413-
stats.wrap_header = true;
414-
stats.wrap_length = true;
415-
std::string glob = config[config::ConfigStdArgs::filter_glob];
413+
stats.wrap_header_ = true;
414+
stats.wrap_length_ = true;
415+
std::string glob = config[config::ConfigStdArgs::filter_glob];
416416
stats.put(Row::make("Filter string", glob));
417417
stats.put(Row::make_row("> Heap Memory"));
418418
stats.put(Row::make("Heap alloc", NumDetectedHeap.getValue()));

lib/passes/analysis/MemOpVisitor.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ MemOpVisitor::MemOpVisitor() : MemOpVisitor(true, true) {
5353
MemOpVisitor::MemOpVisitor(const config::Configuration& config)
5454
: MemOpVisitor(config[config::ConfigStdArgs::stack], config[config::ConfigStdArgs::heap]) {
5555
}
56-
MemOpVisitor::MemOpVisitor(bool collect_allocas, bool collect_heap)
57-
: collect_allocas(collect_allocas), collect_heap(collect_heap) {
56+
MemOpVisitor::MemOpVisitor(bool stack, bool heap) : collect_allocas(stack), collect_heap(heap) {
5857
}
5958

6059
void MemOpVisitor::collect(llvm::Function& function) {
6160
visit(function);
6261

6362
for (auto& [lifetime, alloc] : lifetime_starts) {
64-
auto* data =
65-
llvm::find_if(allocas, [alloc = std::ref(alloc)](const AllocaData& data) { return data.alloca == alloc; });
63+
auto* data = llvm::find_if(
64+
allocas, [alloc = std::ref(alloc)](const AllocaData& alloca_data) { return alloca_data.alloca == alloc; });
6665
if (data != std::end(allocas)) {
6766
data->lifetime_start.insert(lifetime);
6867
}
@@ -132,11 +131,11 @@ llvm::Expected<T*> getSingleUserAs(llvm::Value* value) {
132131
"Expected a single user on value \"{}\" but found multiple potential candidates!", *value);
133132

134133
// This should return the type T we need:
135-
auto user = llvm::find_if(users, [](auto user) { return isa<T>(*user); });
136-
RETURN_ERROR_IF(user == std::end(users),
134+
auto found_user = llvm::find_if(users, [](auto user) { return isa<T>(*user); });
135+
RETURN_ERROR_IF(found_user == std::end(users),
137136
"Expected a single user on value \"{}\" but didn't find a user of the desired type!", *value);
138137

139-
return {dyn_cast<T>(*user)};
138+
return {dyn_cast<T>(*found_user)};
140139
}
141140

142141
using MallocGeps = SmallPtrSet<GetElementPtrInst*, 2>;

lib/passes/analysis/MemOpVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct MemOpVisitor : public llvm::InstVisitor<MemOpVisitor> {
4343
public:
4444
MemOpVisitor();
4545
explicit MemOpVisitor(const config::Configuration& config);
46-
MemOpVisitor(bool collect_allocas, bool collect_heap);
46+
MemOpVisitor(bool stack, bool heap);
4747
void collect(llvm::Function& function);
4848
void collectGlobals(llvm::Module& module);
4949
void clear();

lib/passes/filter/FilterBase.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ enum class FilterAnalysis {
4141

4242
template <typename CallSiteHandler, typename Search, typename OmpHelper = omp::EmptyContext>
4343
class BaseFilter : public Filter {
44-
CallSiteHandler handler;
44+
CallSiteHandler callsite_handler;
4545
Search search_dir{};
4646
bool malloc_mode{false};
4747
llvm::Function* start_f{nullptr};
4848

4949
public:
50-
explicit BaseFilter(const CallSiteHandler& handler) : handler(handler) {
50+
explicit BaseFilter(const CallSiteHandler& handler) : callsite_handler(handler) {
5151
}
5252

5353
template <typename... Args>
54-
explicit BaseFilter(Args&&... args) : handler(std::forward<Args>(args)...) {
54+
explicit BaseFilter(Args&&... args) : callsite_handler(std::forward<Args>(args)...) {
5555
}
5656

5757
bool filter(llvm::Value* in) override {
@@ -83,7 +83,7 @@ class BaseFilter : public Filter {
8383
// is null in case of global:
8484
llvm::Function* currentF = fpath.getCurrentFunc();
8585
if (currentF != nullptr) {
86-
auto status = handler.precheck(current, currentF, fpath);
86+
auto status = callsite_handler.precheck(current, currentF, fpath);
8787
switch (status) {
8888
case FilterAnalysis::Filter:
8989
fpath.pop();
@@ -232,7 +232,7 @@ class BaseFilter : public Filter {
232232
// Indirect calls (sth. like function pointers)
233233
if (indirect_call) {
234234
if constexpr (CallSiteHandler::Support::Indirect) {
235-
auto status = handler.indirect(site, path);
235+
auto status = callsite_handler.indirect(site, path);
236236
LOG_DEBUG("Indirect call: " << util::try_demangle(site))
237237
return status;
238238
} else {
@@ -248,7 +248,7 @@ class BaseFilter : public Filter {
248248
if (is_decl) {
249249
if (is_intrinsic) {
250250
if constexpr (CallSiteHandler::Support::Intrinsic) {
251-
auto status = handler.intrinsic(site, path);
251+
auto status = callsite_handler.intrinsic(site, path);
252252
LOG_DEBUG("Intrinsic call: " << util::try_demangle(site))
253253
return status;
254254
} else {
@@ -272,7 +272,7 @@ class BaseFilter : public Filter {
272272

273273
// Handle decl (like MPI calls)
274274
if constexpr (CallSiteHandler::Support::Declaration) {
275-
auto status = handler.decl(site, path);
275+
auto status = callsite_handler.decl(site, path);
276276
LOG_DEBUG("Decl call: " << util::try_demangle(site))
277277
return status;
278278
} else {
@@ -282,7 +282,7 @@ class BaseFilter : public Filter {
282282
} else {
283283
// Handle definitions
284284
if constexpr (CallSiteHandler::Support::Definition) {
285-
auto status = handler.def(site, path);
285+
auto status = callsite_handler.def(site, path);
286286
LOG_DEBUG("Defined call: " << util::try_demangle(site))
287287
return status;
288288
} else {

lib/passes/filter/FilterUtil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ inline bool isTempAlloc(llvm::Value* in) {
160160
for (auto& args : f->args()) {
161161
if (&args == store->getValueOperand()) {
162162
match = true;
163-
return util::DefUseChain::cancel;
163+
return util::DefUseChain::kCancel;
164164
}
165165
}
166166
}
167-
return util::DefUseChain::no_match;
167+
return util::DefUseChain::kNoMatch;
168168
});
169169

170170
return match;

lib/passes/filter/Matcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FunctionOracleMatcher final : public Matcher {
7575
const auto f = c.getCalledFunction();
7676
if (f != nullptr) {
7777
const auto f_name = util::demangle(f->getName());
78-
StringRef f_name_ref{f_name};
78+
llvm::StringRef f_name_ref{f_name};
7979
if (continue_set.count(f_name) > 0) {
8080
return MatchResult::ShouldContinue;
8181
}

lib/passes/filter/OmpUtil.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ struct OmpContext {
145145

146146
if (called != nullptr && util::starts_with_any_of(called->getName(), "__kmpc_omp_task(")) {
147147
found = true;
148-
return util::DefUseChain::cancel;
148+
return util::DefUseChain::kCancel;
149149
}
150150
}
151-
return util::DefUseChain::no_match;
151+
return util::DefUseChain::kNoMatch;
152152
});
153153
return found;
154154
}
@@ -170,9 +170,9 @@ struct OmpContext {
170170
auto calls = util::find_all(f, [&](auto& inst) {
171171
llvm::CallSite s(&inst);
172172
if (s.isCall() || s.isInvoke()) {
173-
if (auto f = s.getCalledFunction()) {
173+
if (auto called_function = s.getCalledFunction()) {
174174
// once true, the find_all should cancel
175-
return util::starts_with_any_of(f->getName(), "__kmpc_omp_task_alloc");
175+
return util::starts_with_any_of(called_function->getName(), "__kmpc_omp_task_alloc");
176176
}
177177
}
178178
return false;
@@ -184,9 +184,9 @@ struct OmpContext {
184184
chain.traverse(i, [&v, &found](auto val) {
185185
if (v == val) {
186186
found = true;
187-
return util::DefUseChain::cancel;
187+
return util::DefUseChain::kCancel;
188188
}
189-
return util::DefUseChain::no_match;
189+
return util::DefUseChain::kNoMatch;
190190
});
191191
if (found) {
192192
return true;

lib/passes/instrumentation/TypeARTFunctions.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ using namespace llvm;
3737

3838
namespace typeart {
3939

40-
TAFunctionDeclarator::TAFunctionDeclarator(Module& m, InstrumentationHelper&, TAFunctions& tafunc)
41-
: m(m), tafunc(tafunc) {
40+
TAFunctionDeclarator::TAFunctionDeclarator(Module& mod, InstrumentationHelper&, TAFunctions& typeart_funcs)
41+
: module(mod), typeart_functions(typeart_funcs) {
4242
}
4343

44-
llvm::Function* TAFunctionDeclarator::make_function(IFunc id, llvm::StringRef basename,
44+
llvm::Function* TAFunctionDeclarator::make_function(IFunc func_id, llvm::StringRef basename,
4545
llvm::ArrayRef<llvm::Type*> args, bool with_omp, bool fixed_name) {
46-
const auto make_fname = [&fixed_name](llvm::StringRef name, llvm::ArrayRef<llvm::Type*> args, bool with_omp) {
46+
const auto make_fname = [&fixed_name](llvm::StringRef name, llvm::ArrayRef<llvm::Type*> callback_arguments,
47+
bool with_omp_postfix) {
4748
std::string fname;
4849
llvm::raw_string_ostream os(fname);
4950
os << name;
5051

5152
if (!fixed_name) {
52-
os << "_" << std::to_string(args.size());
53+
os << "_" << std::to_string(callback_arguments.size());
5354
}
54-
if (with_omp) {
55+
if (with_omp_postfix) {
5556
os << "_"
5657
<< "omp";
5758
}
@@ -60,11 +61,11 @@ llvm::Function* TAFunctionDeclarator::make_function(IFunc id, llvm::StringRef ba
6061

6162
const auto name = make_fname(basename, args, with_omp);
6263

63-
if (auto it = f_map.find(name); it != f_map.end()) {
64+
if (auto it = function_map.find(name); it != function_map.end()) {
6465
return it->second;
6566
}
6667

67-
auto& c = m.getContext();
68+
auto& c = module.getContext();
6869
const auto addOptimizerAttributes = [&](llvm::Function* function) {
6970
function->setDoesNotThrow();
7071
function->setDoesNotFreeMemory();
@@ -84,13 +85,13 @@ llvm::Function* TAFunctionDeclarator::make_function(IFunc id, llvm::StringRef ba
8485
function->setLinkage(GlobalValue::ExternalLinkage);
8586
// f->setLinkage(GlobalValue::ExternalWeakLinkage);
8687
};
87-
const auto do_make = [&](auto& name, auto f_type) {
88-
const bool has_func_declared = m.getFunction(name) != nullptr;
89-
auto func_in_module = m.getOrInsertFunction(name, f_type);
88+
const auto do_make = [&](auto& function_name, auto function_type) {
89+
const bool has_func_declared = module.getFunction(function_name) != nullptr;
90+
auto func_in_module = module.getOrInsertFunction(function_name, function_type);
9091

9192
Function* function{nullptr};
9293
if (has_func_declared) {
93-
LOG_WARNING("Function " << name << " is already declared in the module.")
94+
LOG_WARNING("Function " << function_name << " is already declared in the module.")
9495
function = dyn_cast<Function>(func_in_module.getCallee()->stripPointerCasts());
9596
} else {
9697
function = dyn_cast<Function>(func_in_module.getCallee());
@@ -101,17 +102,17 @@ llvm::Function* TAFunctionDeclarator::make_function(IFunc id, llvm::StringRef ba
101102
return function;
102103
};
103104

104-
auto f = do_make(name, FunctionType::get(Type::getVoidTy(c), args, false));
105+
auto generated_function = do_make(name, FunctionType::get(Type::getVoidTy(c), args, false));
105106

106-
f_map[name] = f;
107+
function_map[name] = generated_function;
107108

108-
tafunc.putFunctionFor(id, f);
109+
typeart_functions.putFunctionFor(func_id, generated_function);
109110

110-
return f;
111+
return generated_function;
111112
}
112113

113114
const llvm::StringMap<llvm::Function*>& TAFunctionDeclarator::getFunctionMap() const {
114-
return f_map;
115+
return function_map;
115116
}
116117

117118
TAFunctions::TAFunctions() = default;

0 commit comments

Comments
 (0)