Skip to content

Conversation

@jzc
Copy link
Contributor

@jzc jzc commented Oct 31, 2024

No description provided.

@jzc jzc requested a review from a team as a code owner October 31, 2024 15:15
@jzc jzc temporarily deployed to WindowsCILock October 31, 2024 15:17 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock October 31, 2024 16:10 — with GitHub Actions Inactive
Comment on lines 933 to 941
bool dummyEmitted = false;
for (module_split::ModuleDesc &IrMD : MMs) {
if (auto Dummy = makeDummy(IrMD)) {
saveModule(Tables, *Dummy, ID, OutIRFileName, /*IsDummy*/ true);
dummyEmitted = true;
}
}
if (dummyEmitted)
++ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We either need some comments here, or the function should be renamed (and likely we need both).

For an unfamiliar reader it could be a mystery what "dummy" means and why do we need to make it for every device image we have produced.

Also: do we have any information about device image carrying virtual function definitions in ModuleDesc, or any of its members? If we had an if like that at this level, it would save us function arguments lookup and would work as an extra documentation piece

++ID;
}

bool dummyEmitted = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool dummyEmitted = false;
bool DummyEmitted = false;


std::optional<module_split::ModuleDesc>
makeDummy(module_split::ModuleDesc &MD) {
bool hasVirtualFunctions = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool hasVirtualFunctions = false;
bool HasVirtualFunctions = false;

LLVM Coding Standards

; CHECK-FP64-DUMMY-NEXT: entry:
; CHECK-FP64-DUMMY-NEXT: ret void

; CHECK-FP64-DUMMY-PROPS: dummy=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also check that we have not emitted the property for other device images. And I would also throw a virtual function without any optional kernel features on it into the mix as well

@jzc jzc temporarily deployed to WindowsCILock December 5, 2024 15:43 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock December 5, 2024 17:39 — with GitHub Actions Inactive
}

ModuleDesc ModuleDesc::makeDummy() const {
ModuleDesc MD(CloneModule(getModule()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we are cloning the module two times: first time here and then during call to ModuleDesc::makeDummyImageIR within saveModuleIR and I don't think that we really need this first clone.

I suggest that we call saveModuleIR here immediately, thus saving a module copy (they are generally expensive).


void saveSplitInformationAsMetadata();

ModuleDesc makeDummy() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ModuleDesc makeDummy() const;
ModuleDesc makeDummyCopy() const;

To better indicate that it creates a clone. Otherwise the name may suggest that it simply modifies the existing ModuleDesc


std::string saveModuleIR(Module &M, int I, StringRef Suff) {
DUMP_ENTRY_POINTS(M, EmitOnlyKernelsAsEntryPoints, "saving IR");
std::unique_ptr<Module> makeDummyImageIR(const Module &M) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we do code split we don't clone the whole module, but we only take what's necessary.

As I understand it, the input here is a device image which contains virtual function definitions. But the code below suggests that it also may contain other functions which are called by virtual functions. If we can save on copying them, then we probably should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants