This is an archive of the discontinued LLVM Phabricator instance.

Allow common linkage global var have non-zero initializer
AbandonedPublic

Authored by yaxunl on Dec 7 2016, 2:47 PM.

Details

Reviewers
tstellarAMD
Summary

In C99 tentative definition of file-scope variable results in common linkage, e.g.

private char *p;
private char *p;

which are initialized by default initializer. For pointer type global variable, the default initializer is null pointer, which does not necessarily have zero value. If a structure contains pointer type member for which null pointer does not have zero value, the strucutre cannot be initialized with zeroinitializer.

Currently IR Verifier asserts when a global variable with common linkage has an initializer which is not zeroinitializer, which it should not. This patch fixes that.

Diff Detail

Event Timeline

yaxunl updated this revision to Diff 80668.Dec 7 2016, 2:47 PM
yaxunl retitled this revision from to Allow common linkage global var have non-zero initializer.
yaxunl updated this object.
yaxunl added a reviewer: tstellarAMD.
yaxunl added a subscriber: llvm-commits.
yaxunl abandoned this revision.Dec 12 2016, 2:25 PM

This is not right solution since global variable with common linkage does not have explicit section. Use weak linkage for global variables with non-zero initializer instead.