This is an archive of the discontinued LLVM Phabricator instance.

Declares __cpu_model as dso local
ClosedPublic

Authored by hhb on Oct 29 2018, 4:55 PM.

Details

Summary


__builtin_cpu_supports and __builtin_cpu_is use information in __cpu_model to decide cpu features. Before this change, __cpu_model was not declared as dso local. The generated code looks up the address in GOT when reading __cpu_model. This makes it impossible to use these functions in ifunc, because at that time GOT entries have not been relocated. This change makes it dso local.

Diff Detail

Event Timeline

hhb created this revision.Oct 29 2018, 4:55 PM
hhb edited the summary of this revision. (Show Details)
hhb edited the summary of this revision. (Show Details)
hhb edited the summary of this revision. (Show Details)Oct 29 2018, 4:57 PM
pirama edited reviewers, added: echristo, craig.topper; removed: pirama.Oct 29 2018, 5:05 PM
pirama added subscribers: srhines, pirama, cfe-commits.

Adding reviewers suggested by 'arc cover'.

craig.topper added inline comments.Oct 29 2018, 5:15 PM
lib/CodeGen/CGBuiltin.cpp
9101

This code looks to be out of date. It's missing the changes from r344832 that added another runtime variable that presumably has the same issue.

hhb updated this revision to Diff 171748.Oct 30 2018, 11:45 AM
hhb updated this revision to Diff 171787.Oct 30 2018, 1:55 PM

Rebase. Change to SetDSOLocal.

hhb updated this revision to Diff 171789.Oct 30 2018, 1:58 PM
hhb marked an inline comment as done.
hhb retitled this revision from Declares __cpu_model as hidden symbol to Declares __cpu_model as dso local.
hhb edited the summary of this revision. (Show Details)
hhb added inline comments.Oct 30 2018, 2:14 PM
lib/CodeGen/CGBuiltin.cpp
9101

By the way, what is the reason for gcc to add a separate cpu_feature2, but not adding an element to cpu_model.__cpu_features array?

hhb set the repository for this revision to rC Clang.Oct 30 2018, 2:41 PM
hhb added a comment.Nov 16 2018, 11:38 AM

Anyone can have a look at this change?

hhb marked an inline comment as done.Nov 21 2018, 10:37 AM

Craig, does this look ok now?

This revision is now accepted and ready to land.Dec 3 2018, 5:41 PM
This revision was automatically updated to reflect the committed changes.