Skip to content

Commit bb701d5

Browse files
authored
Merge branch 'master' into benchmarks
2 parents 5e610a5 + cfa004b commit bb701d5

File tree

85 files changed

+5395
-2244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5395
-2244
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13758
1+
13805
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13766
1+
13813

.github/workflows/ClangTidy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ jobs:
3131

3232
- name: "Run clang tidy"
3333
run: make tidy
34+
35+
- name: "Run check-includes"
36+
run: make check-includes

Makefile.rules

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,42 @@ endif
168168
################################################################################
169169
# Documentation rules
170170

171+
.PHONY: docclean docs
172+
171173
docclean:
172174
rm -rf doc
173175

174-
docs: .PHONY
176+
docs:
175177
mkdir -p docs
176178
doxygen doxygen.conf
177179

178-
.PHONY:
179-
180180
#################################################################################
181181
# Clang format rules
182182

183+
.PHONY: format format-dry-run
184+
183185
format:
184186
clang-format-$(LLVM_VERSION) --Werror --style="file:.clang-format" --verbose -i $(SOURCES) $(HEADERS)
185187

186188
format-dry-run:
187189
clang-format-$(LLVM_VERSION) --dry-run --Werror --style="file:.clang-format" --verbose -i $(SOURCES) $(HEADERS)
188190

189191
#################################################################################
190-
# Clang tidy rules
192+
# Linting rules
193+
194+
.PHONY: tidy check-includes
191195

192196
tidy: $(COMMANDPATHSFILE)
193197
# Run clang-tidy in parallel on all source files and headers, halt on first error
194198
parallel --halt now,fail=1 \
195199
clang-tidy-$(LLVM_VERSION) --config-file=.clang-tidy {} -- $(CXXFLAGS) $(CPPFLAGS) -I$(BUILD_OUT_PREFIX) \
196200
::: $(HEADERS) $(SOURCES)
201+
202+
203+
check-includes:
204+
# Check that no #include statements use regular "-quoutes
205+
# Ignore files in rhls2firrtl as it contains strings used in code harness generation
206+
@if ( git --no-pager grep -E "^#include \"" -- ":!jlm/hls/backend/rhls2firrtl" ); then \
207+
echo "error: failed due to the above #include directives using \"-style quotes"; \
208+
exit 1; \
209+
fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ following articles:
113113
H. R. Krogstie, H. Bahmann, M. Själander, and N. Reissmann
114114
*"PIP: Making Andersen's Points-to Analysis Sound and Practical for Incomplete C Programs"*
115115
Proceedings of the ACM/IEEE International Conference on Code Generation and Optimization (CGO), Feb. 2026.
116-
https://www.arxiv.org/pdf/2512.07299
116+
https://doi.org/10.1109/CGO68049.2026.11395202
117117

118118
D. Metz, N. Reissmann, and M. Själander
119119
*"R-HLS: An IR for Dynamic High-Level Synthesis and Memory Disambiguation based on Regions and State Edges"*

jlm/hls/backend/rvsdg2rhls/add-prints.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ convert_prints(llvm::LlvmRvsdgModule & rm)
5959
// TODO: make this less hacky by using the correct state types
6060
auto fct =
6161
rvsdg::FunctionType::Create({ rvsdg::BitType::Create(64), rvsdg::BitType::Create(64) }, {});
62-
auto & printf =
63-
llvm::LlvmGraphImport::Create(graph, fct, fct, "printnode", llvm::Linkage::externalLinkage);
62+
auto & printf = llvm::LlvmGraphImport::Create(
63+
graph,
64+
fct,
65+
fct,
66+
"printnode",
67+
llvm::Linkage::externalLinkage,
68+
false,
69+
1);
6470
convert_prints(root, &printf, fct);
6571
}
6672

@@ -91,7 +97,11 @@ convert_prints(
9197
JLM_ASSERT(bt);
9298
val = &llvm::ZExtOperation::Create(*val, rvsdg::BitType::Create(64));
9399
}
94-
llvm::CallOperation::Create(printf_local, functionType, { constantNode.output(0), val });
100+
llvm::CallOperation::Create(
101+
printf_local,
102+
functionType,
103+
llvm::AttributeList::createEmptyList(),
104+
{ constantNode.output(0), val });
95105
node->output(0)->divert_users(node->input(0)->origin());
96106
jlm::rvsdg::remove(node);
97107
}

jlm/hls/backend/rvsdg2rhls/hls-function-util.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
#ifndef JLM_HLS_BACKEND_RVSDG2RHLS_HLS_FUNCTION_UTIL_HPP
66
#define JLM_HLS_BACKEND_RVSDG2RHLS_HLS_FUNCTION_UTIL_HPP
77

8-
#include "jlm/llvm/ir/operators/IntegerOperations.hpp"
9-
#include <deque>
8+
#include <jlm/llvm/ir/operators/IntegerOperations.hpp>
109
#include <jlm/llvm/ir/RvsdgModule.hpp>
1110
#include <jlm/rvsdg/lambda.hpp>
1211

12+
#include <deque>
13+
1314
namespace jlm::hls
1415
{
1516
bool

jlm/hls/backend/rvsdg2rhls/instrument-ref.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ instrument_ref(llvm::LlvmRvsdgModule & rm)
9797
loadFunctionType,
9898
loadFunctionType,
9999
"reference_load",
100-
llvm::Linkage::externalLinkage);
100+
llvm::Linkage::externalLinkage,
101+
false,
102+
1);
101103
auto & reference_store = llvm::LlvmGraphImport::Create(
102104
graph,
103105
loadFunctionType,
104106
loadFunctionType,
105107
"reference_store",
106-
llvm::Linkage::externalLinkage);
108+
llvm::Linkage::externalLinkage,
109+
false,
110+
1);
107111
// addr, size, memstate
108112
auto allocaFunctionType = jlm::rvsdg::FunctionType::Create(
109113
{ jlm::llvm::PointerType::Create(),
@@ -116,7 +120,9 @@ instrument_ref(llvm::LlvmRvsdgModule & rm)
116120
allocaFunctionType,
117121
allocaFunctionType,
118122
"reference_alloca",
119-
llvm::Linkage::externalLinkage);
123+
llvm::Linkage::externalLinkage,
124+
false,
125+
1);
120126

121127
instrument_ref(
122128
root,
@@ -182,6 +188,7 @@ instrument_ref(
182188
auto callOp = jlm::llvm::CallOperation::Create(
183189
load_func,
184190
loadFunctionType,
191+
llvm::AttributeList::createEmptyList(),
185192
{ addr, widthNode.output(0), ioState, memstate });
186193
// Divert the memory state of the load to the new memstate from the call operation
187194
node->input(1)->divert_to(callOp[1]);
@@ -216,6 +223,7 @@ instrument_ref(
216223
auto callOp = jlm::llvm::CallOperation::Create(
217224
alloca_func,
218225
allocaFunctionType,
226+
llvm::AttributeList::createEmptyList(),
219227
{ addr, sizeNode.output(0), ioState, memstate });
220228
for (auto ou : old_users)
221229
{
@@ -245,6 +253,7 @@ instrument_ref(
245253
auto callOp = jlm::llvm::CallOperation::Create(
246254
store_func,
247255
storeFunctionType,
256+
llvm::AttributeList::createEmptyList(),
248257
{ addr, widthNode.output(0), ioState, memstate });
249258
// Divert the memory state after the store to the new memstate from the call operation
250259
for (auto user : oldUsers)

jlm/hls/backend/rvsdg2rhls/rvsdg2rhls.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ split_opt(llvm::LlvmRvsdgModule & rm)
6363
// TODO: figure out which optimizations to use here
6464
jlm::llvm::DeadNodeElimination dne;
6565
CommonNodeElimination cne;
66-
jlm::llvm::InvariantValueRedirection ivr;
66+
constexpr llvm::InvariantValueRedirection::Configuration ivrConfiguration;
67+
llvm::InvariantValueRedirection invariantValueRedirection(std::move(ivrConfiguration));
6768
llvm::LoopUnswitching loopUnswitching(llvm::LoopUnswitchingDefaultHeuristic::create());
6869
jlm::llvm::NodeReduction red;
6970
jlm::util::StatisticsCollector statisticsCollector;
7071
loopUnswitching.Run(rm, statisticsCollector);
7172
dne.Run(rm, statisticsCollector);
7273
cne.Run(rm, statisticsCollector);
73-
ivr.Run(rm, statisticsCollector);
74+
invariantValueRedirection.Run(rm, statisticsCollector);
7475
red.Run(rm, statisticsCollector);
7576
dne.Run(rm, statisticsCollector);
7677
}
@@ -81,13 +82,14 @@ pre_opt(jlm::llvm::LlvmRvsdgModule & rm)
8182
// TODO: figure out which optimizations to use here
8283
jlm::llvm::DeadNodeElimination dne;
8384
CommonNodeElimination cne;
84-
jlm::llvm::InvariantValueRedirection ivr;
85+
constexpr llvm::InvariantValueRedirection::Configuration ivrConfiguration;
86+
llvm::InvariantValueRedirection invariantValueRedirection(std::move(ivrConfiguration));
8587
llvm::LoopUnswitching loopUnswitching(llvm::LoopUnswitchingDefaultHeuristic::create());
8688
jlm::util::StatisticsCollector statisticsCollector;
8789
loopUnswitching.Run(rm, statisticsCollector);
8890
dne.Run(rm, statisticsCollector);
8991
cne.Run(rm, statisticsCollector);
90-
ivr.Run(rm, statisticsCollector);
92+
invariantValueRedirection.Run(rm, statisticsCollector);
9193
dne.Run(rm, statisticsCollector);
9294
cne.Run(rm, statisticsCollector);
9395
dne.Run(rm, statisticsCollector);
@@ -207,7 +209,8 @@ rename_delta(rvsdg::DeltaNode * odn)
207209
name,
208210
llvm::Linkage::externalLinkage,
209211
"",
210-
op->constant()));
212+
op->constant(),
213+
op->getAlignment()));
211214
/* add dependencies */
212215
rvsdg::SubstitutionMap rmap;
213216
for (auto ctxVar : odn->GetContextVars())
@@ -303,7 +306,9 @@ split_hls_function(llvm::LlvmRvsdgModule & rm, const std::string & function_name
303306
oldGraphImport->ValueType(),
304307
oldGraphImport->ImportedType(),
305308
oldGraphImport->Name(),
306-
oldGraphImport->linkage());
309+
oldGraphImport->linkage(),
310+
oldGraphImport->isConstant(),
311+
oldGraphImport->getAlignment());
307312
smap.insert(ln->input(i)->origin(), &newGraphImport);
308313
continue;
309314
}
@@ -331,7 +336,9 @@ split_hls_function(llvm::LlvmRvsdgModule & rm, const std::string & function_name
331336
op->Type(),
332337
llvm::PointerType::Create(),
333338
op->name(),
334-
llvm::Linkage::externalLinkage);
339+
llvm::Linkage::externalLinkage,
340+
op->constant(),
341+
op->getAlignment());
335342
smap.insert(ln->input(i)->origin(), &graphImport);
336343
// add export for delta to rm
337344
// TODO: check if not already exported and maybe adjust linkage?
@@ -354,7 +361,9 @@ split_hls_function(llvm::LlvmRvsdgModule & rm, const std::string & function_name
354361
op.Type(),
355362
op.Type(),
356363
op.name(),
357-
llvm::Linkage::externalLinkage); // TODO: change linkage?
364+
llvm::Linkage::externalLinkage, // TODO: change linkage?
365+
false,
366+
1);
358367
ln->output()->divert_users(&graphImport);
359368
remove(ln);
360369
std::cout << "function "
@@ -378,7 +387,8 @@ createTransformationSequence(rvsdg::DotWriter & dotWriter, const bool dumpRvsdgD
378387
auto predicateCorrelation = std::make_shared<llvm::PredicateCorrelation>();
379388
auto deadNodeElimination = std::make_shared<llvm::DeadNodeElimination>();
380389
auto commonNodeElimination = std::make_shared<CommonNodeElimination>();
381-
auto invariantValueRedirection = std::make_shared<llvm::InvariantValueRedirection>();
390+
auto invariantValueRedirection = std::make_shared<llvm::InvariantValueRedirection>(
391+
llvm::InvariantValueRedirection::Configuration());
382392
auto loopUnswitching =
383393
std::make_shared<llvm::LoopUnswitching>(llvm::LoopUnswitchingDefaultHeuristic::create());
384394
auto ioBarrierRemoval = std::make_shared<IOBarrierRemoval>();

jlm/llvm/Makefile.sub

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ libllvm_SOURCES = \
1010
\
1111
jlm/llvm/frontend/ControlFlowRestructuring.cpp \
1212
jlm/llvm/frontend/InterProceduralGraphConversion.cpp \
13-
jlm/llvm/frontend/LlvmInstructionConversion.cpp \
1413
jlm/llvm/frontend/LlvmModuleConversion.cpp \
1514
\
1615
jlm/llvm/ir/aggregation.cpp \
@@ -67,6 +66,7 @@ libllvm_SOURCES = \
6766
jlm/llvm/opt/inlining.cpp \
6867
jlm/llvm/opt/InvariantValueRedirection.cpp \
6968
jlm/llvm/opt/LoadChainSeparation.cpp \
69+
jlm/llvm/opt/LoopStrengthReduction.cpp \
7070
jlm/llvm/opt/LoopUnswitching.cpp \
7171
jlm/llvm/opt/PredicateCorrelation.cpp \
7272
jlm/llvm/opt/pull.cpp \
@@ -113,15 +113,14 @@ libllvm_HEADERS = \
113113
jlm/llvm/opt/IfConversion.hpp \
114114
jlm/llvm/opt/InvariantValueRedirection.hpp \
115115
jlm/llvm/opt/LoadChainSeparation.hpp \
116+
jlm/llvm/opt/LoopStrengthReduction.hpp \
116117
jlm/llvm/opt/LoopUnswitching.hpp \
117118
jlm/llvm/opt/PredicateCorrelation.hpp \
118119
jlm/llvm/opt/RvsdgTreePrinter.hpp \
119120
jlm/llvm/opt/ScalarEvolution.hpp \
120121
jlm/llvm/opt/StoreValueForwarding.hpp \
121122
jlm/llvm/frontend/LlvmModuleConversion.hpp \
122123
jlm/llvm/frontend/ControlFlowRestructuring.hpp \
123-
jlm/llvm/frontend/LlvmConversionContext.hpp \
124-
jlm/llvm/frontend/LlvmInstructionConversion.hpp \
125124
jlm/llvm/frontend/InterProceduralGraphConversion.hpp \
126125
jlm/llvm/ir/operators.hpp \
127126
jlm/llvm/ir/ipgraph-module.hpp \
@@ -169,6 +168,7 @@ tests/jlm/llvm/run-libllvm-tests_SOURCES = \
169168
tests/jlm/llvm/backend/IpGraphToLlvmConverterTests.cpp \
170169
tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests.cpp \
171170
\
171+
tests/jlm/llvm/frontend/llvm/CastingTests.cpp \
172172
tests/jlm/llvm/frontend/llvm/ControlFlowRestructuringTests.cpp \
173173
tests/jlm/llvm/frontend/llvm/LoadTests.cpp \
174174
tests/jlm/llvm/frontend/llvm/MemCpyTests.cpp \
@@ -231,6 +231,7 @@ tests/jlm/llvm/run-libllvm-tests_SOURCES = \
231231
tests/jlm/llvm/opt/IfConversionTests.cpp \
232232
tests/jlm/llvm/opt/InvariantValueRedirectionTests.cpp \
233233
tests/jlm/llvm/opt/LoadChainSeparationTests.cpp \
234+
tests/jlm/llvm/opt/LoopStrengthReductionTests.cpp \
234235
tests/jlm/llvm/opt/LoopUnswitchingTests.cpp \
235236
tests/jlm/llvm/opt/NodeReductionTests.cpp \
236237
tests/jlm/llvm/opt/PredicateCorrelationTests.cpp \

0 commit comments

Comments
 (0)