Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR][Codegen] Fixes global variables that point to another globals #1277

Merged
merged 32 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d7d7b73
kind of works, but dirty and tests fail
gitoleg Dec 25, 2024
b4a3f15
wip
gitoleg Dec 25, 2024
0252585
[CIR][CodeGen] handle zero init padding case
gitoleg Dec 25, 2024
73436cd
use zero index
gitoleg Dec 25, 2024
f2fc318
refactoring
gitoleg Dec 25, 2024
089364d
handle const arrays
gitoleg Dec 25, 2024
517a89d
wip
gitoleg Dec 26, 2024
9cb7e34
wip, refacroting
gitoleg Dec 26, 2024
f5070b7
wip
gitoleg Dec 28, 2024
30c536f
fixed tests, removed zero index for vtt
gitoleg Jan 9, 2025
1704b37
adds LLVM checks in tests
gitoleg Jan 9, 2025
9b9ae91
[CIR][CodeGen] handle zero init padding case (#1257)
gitoleg Jan 9, 2025
422a663
refactoring wip
gitoleg Jan 10, 2025
0484510
bug fixed
gitoleg Jan 10, 2025
5ac7673
clang-format ...
gitoleg Jan 10, 2025
6349b85
changes after review
gitoleg Jan 13, 2025
d45b5f8
clang-format ...
gitoleg Jan 13, 2025
6150116
minor
gitoleg Jan 13, 2025
9d4e0d7
minor
gitoleg Jan 15, 2025
54ed360
minor
gitoleg Jan 15, 2025
111c9ac
rm leading zero const idx
gitoleg Jan 16, 2025
b538bea
bug fixing
gitoleg Jan 24, 2025
661e4a4
renaming
gitoleg Jan 24, 2025
7c09a9b
fixes multi dim array
gitoleg Jan 27, 2025
44ac729
create new view only for the proper globs
gitoleg Jan 27, 2025
85b8ee5
fixed bug with nested strucutres
gitoleg Jan 28, 2025
c7954a8
fixes tests
gitoleg Jan 29, 2025
a1595a8
clang-format ...
gitoleg Jan 29, 2025
28e1772
wip
gitoleg Jan 29, 2025
ff563c3
minor fix
gitoleg Feb 4, 2025
072a796
Merge remote-tracking branch 'upstream/main' into fix-globals-pointed…
gitoleg Feb 4, 2025
2f2c844
fixing tests
gitoleg Feb 4, 2025
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
Prev Previous commit
Next Next commit
bug fixed
gitoleg committed Jan 29, 2025
commit 04845100a6cff0a7096698ac9b4078b6331ab2a2
17 changes: 8 additions & 9 deletions clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
Original file line number Diff line number Diff line change
@@ -114,19 +114,18 @@ void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset(

uint64_t CIRGenBuilderTy::computeOffsetFromGlobalViewIndices(
const cir::CIRDataLayout& layout,
mlir::Type t,
llvm::ArrayRef<uint64_t> indexes) {
mlir::Type typ,
llvm::ArrayRef<uint64_t> indexes) {

mlir::Type elt;
uint64_t offset = 0;
for (auto idx : indexes) {
if (auto sTy = dyn_cast<cir::StructType>(t)) {
offset = sTy.getElementOffset(layout.layout, idx);
if (auto sTy = dyn_cast<cir::StructType>(typ)) {
offset += sTy.getElementOffset(layout.layout, idx);
assert(idx < sTy.getMembers().size());
elt = sTy.getMembers()[idx];
} else if (auto arTy = dyn_cast<cir::ArrayType>(t)) {
elt = arTy.getEltType();
offset = layout.getTypeAllocSize(elt) * idx;
typ = sTy.getMembers()[idx];
} else if (auto arTy = dyn_cast<cir::ArrayType>(typ)) {
typ = arTy.getEltType();
offset += layout.getTypeAllocSize(typ) * idx;
} else {
llvm_unreachable("NYI");
}