This is an archive of the discontinued LLVM Phabricator instance.

ThinLTOBitcodeWriter: handle aliases first in filterModule
ClosedPublic

Authored by inglorion on Apr 3 2017, 5:14 PM.

Details

Summary

This change fixes a "local linkage requires default visibility" assert when attempting to build LLVM with ThinLTO on Windows.

Diff Detail

Repository
rL LLVM

Event Timeline

inglorion created this revision.Apr 3 2017, 5:14 PM
mehdi_amini edited edge metadata.Apr 3 2017, 5:15 PM

Do you have a test case?

The test for this change is in D31633.

I see the clang test. We try to keep our testing at the IR level though. Is there anything specific that prevents it in this case?

@mehdi_amini: This is reduced from a C++ program that triggered the problem. The compiler failed before outputing IR, which is why it is C++. I can try to see if I can create some IR that will reproduce the problem, but it will have to wait until tomorrow.

Thanks, @pcc for helping me look into this and realizing that doing the alias processing first fixes the problem. I've also included a small change to use GA-> instead of I->, which prevents us from using the iterator in an invalid state and hitting another assert.

inglorion updated this revision to Diff 94118.Apr 4 2017, 2:04 PM

Added LLVM IR test.

pcc added inline comments.Apr 4 2017, 2:21 PM
test/ThinLTO/X86/promote-internals.ll
1 ↗(On Diff #94118)

This is a test of the ThinLTOBitcodeWriter so it should live in test/Transforms/ThinLTOBitcodeWriter.

2 ↗(On Diff #94118)

Please use llvm-modextract and llvm-dis to check that the IR is as expected.

13–21 ↗(On Diff #94118)

Do you need these functions? I think you should be able to trigger the bug without them if you give @al external linkage.

inglorion updated this revision to Diff 94137.Apr 4 2017, 4:22 PM

addressed @pcc's comments

inglorion added inline comments.Apr 4 2017, 4:27 PM
test/ThinLTO/X86/promote-internals.ll
13–21 ↗(On Diff #94118)

Doing that leads to a different error ("GlobalValue not found in index"). That error is also addressed by this patch (specifically, by the change from I-> to GA->), but can be triggered with or without the change to when we process aliases. For that reason, I've elected to keep the functions in the test - but I can remove them if you really want me to.

pcc added inline comments.Apr 4 2017, 4:44 PM
test/ThinLTO/X86/promote-internals.ll
13–21 ↗(On Diff #94118)

If I make just the I-> to GA-> change locally I still get the "GlobalValue not found in index" assertion failure with your test case with the functions removed. I would just remove them because the assertion failure is being caused by the same underlying issue.

pcc added inline comments.Apr 4 2017, 4:47 PM
test/Transforms/ThinLTOBitcodeWriter/promote-internals.ll
2 ↗(On Diff #94137)

Please also check the contents of both modules here.

inglorion updated this revision to Diff 94147.Apr 4 2017, 5:42 PM

Made changes requested by @pcc

pcc accepted this revision.Apr 4 2017, 5:49 PM

LGTM

test/Transforms/ThinLTOBitcodeWriter/promote-internals.ll
1 ↗(On Diff #94147)

Nit: rename filter-alias.ll

This revision is now accepted and ready to land.Apr 4 2017, 5:49 PM
This revision was automatically updated to reflect the committed changes.