Page MenuHomePhabricator

[X86] Flatten feature dependency tree at compile-time
Needs ReviewPublic

Authored by Nathan-Huckleberry on Aug 12 2020, 11:24 AM.

Details

Summary

Using constexpr we can flatten the feature dependency tree at
compile-time so that no computation is required at run-time.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 11:24 AM
Nathan-Huckleberry requested review of this revision.Aug 12 2020, 11:24 AM
craig.topper added inline comments.Aug 12 2020, 1:51 PM
llvm/lib/Support/X86TargetParser.cpp
581

Doesn't this violate the no global constructor rule?

llvm/lib/Support/X86TargetParser.cpp
581

Oh yikes, yes it does. I tried making the map a function level static variable, but this code is apparently called by multiple threads in some cases so we run into race condition.

Should I switch to a static array and just do a linear search through the array?

Nathan-Huckleberry marked an inline comment as not done.Aug 12 2020, 2:22 PM

Change dependency map to constexpr array to avoid global constructor

Change dependency map to constexpr array to avoid global constructor

Do you have compile time numbers for this after https://reviews.llvm.org/D85807 ?

llvm/lib/Support/X86TargetParser.cpp
583

I've never seen COUNTER before. Is it supported by all the compilers we support. I couldn't find other uses in tree.

void added a subscriber: void.Aug 20 2020, 5:55 PM
void added inline comments.
llvm/lib/Support/X86TargetParser.cpp
583

It is. I believe it's a GNU C feature. But it's heavily used in Linux.