@@ -893,7 +893,8 @@ class PhonyExternalsGenerator : public DefinitionGenerator {
893
893
}
894
894
};
895
895
896
- Expected<std::unique_ptr<Session>> Session::Create (Triple TT) {
896
+ Expected<std::unique_ptr<Session>> Session::Create (Triple TT,
897
+ SubtargetFeatures Features) {
897
898
898
899
std::unique_ptr<ExecutorProcessControl> EPC;
899
900
if (OutOfProcessExecutor.getNumOccurrences ()) {
@@ -923,6 +924,7 @@ Expected<std::unique_ptr<Session>> Session::Create(Triple TT) {
923
924
std::unique_ptr<Session> S (new Session (std::move (EPC), Err));
924
925
if (Err)
925
926
return std::move (Err);
927
+ S->Features = std::move (Features);
926
928
return std::move (S);
927
929
}
928
930
@@ -1223,8 +1225,8 @@ Session::findSymbolInfo(StringRef SymbolName, Twine ErrorMsgStem) {
1223
1225
1224
1226
} // end namespace llvm
1225
1227
1226
- static Triple getFirstFileTriple () {
1227
- static Triple FirstTT = []() {
1228
+ static std::pair< Triple, SubtargetFeatures> getFirstFileTripleAndFeatures () {
1229
+ static std::pair< Triple, SubtargetFeatures> FirstTTAndFeatures = []() {
1228
1230
assert (!InputFiles.empty () && " InputFiles can not be empty" );
1229
1231
for (auto InputFile : InputFiles) {
1230
1232
auto ObjBuffer = ExitOnErr (getFile (InputFile));
@@ -1241,16 +1243,19 @@ static Triple getFirstFileTriple() {
1241
1243
TT.setObjectFormat (Triple::COFF);
1242
1244
TT.setOS (Triple::OSType::Win32);
1243
1245
}
1244
- return TT;
1246
+ SubtargetFeatures Features;
1247
+ if (auto ObjFeatures = Obj->getFeatures ())
1248
+ Features = std::move (*ObjFeatures);
1249
+ return std::make_pair (TT, Features);
1245
1250
}
1246
1251
default :
1247
1252
break ;
1248
1253
}
1249
1254
}
1250
- return Triple ();
1255
+ return std::make_pair ( Triple (), SubtargetFeatures () );
1251
1256
}();
1252
1257
1253
- return FirstTT ;
1258
+ return FirstTTAndFeatures ;
1254
1259
}
1255
1260
1256
1261
static Error sanitizeArguments (const Triple &TT, const char *ArgV0) {
@@ -1808,7 +1813,9 @@ struct TargetInfo {
1808
1813
};
1809
1814
} // anonymous namespace
1810
1815
1811
- static TargetInfo getTargetInfo (const Triple &TT) {
1816
+ static TargetInfo
1817
+ getTargetInfo (const Triple &TT,
1818
+ const SubtargetFeatures &TF = SubtargetFeatures()) {
1812
1819
auto TripleName = TT.str ();
1813
1820
std::string ErrorStr;
1814
1821
const Target *TheTarget = TargetRegistry::lookupTarget (TripleName, ErrorStr);
@@ -1818,7 +1825,7 @@ static TargetInfo getTargetInfo(const Triple &TT) {
1818
1825
inconvertibleErrorCode ()));
1819
1826
1820
1827
std::unique_ptr<MCSubtargetInfo> STI (
1821
- TheTarget->createMCSubtargetInfo (TripleName, " " , " " ));
1828
+ TheTarget->createMCSubtargetInfo (TripleName, " " , TF. getString () ));
1822
1829
if (!STI)
1823
1830
ExitOnErr (
1824
1831
make_error<StringError>(" Unable to create subtarget for " + TripleName,
@@ -1879,7 +1886,7 @@ static Error runChecks(Session &S) {
1879
1886
1880
1887
LLVM_DEBUG (dbgs () << " Running checks...\n " );
1881
1888
1882
- auto TI = getTargetInfo (S.ES .getTargetTriple ());
1889
+ auto TI = getTargetInfo (S.ES .getTargetTriple (), S. Features );
1883
1890
1884
1891
auto IsSymbolValid = [&S](StringRef Symbol) {
1885
1892
return S.isSymbolRegistered (Symbol);
@@ -2026,9 +2033,10 @@ int main(int argc, char *argv[]) {
2026
2033
std::unique_ptr<JITLinkTimers> Timers =
2027
2034
ShowTimes ? std::make_unique<JITLinkTimers>() : nullptr ;
2028
2035
2029
- ExitOnErr (sanitizeArguments (getFirstFileTriple (), argv[0 ]));
2036
+ auto [TT, Features] = getFirstFileTripleAndFeatures ();
2037
+ ExitOnErr (sanitizeArguments (TT, argv[0 ]));
2030
2038
2031
- auto S = ExitOnErr (Session::Create (getFirstFileTriple ( )));
2039
+ auto S = ExitOnErr (Session::Create (std::move (TT), std::move (Features )));
2032
2040
2033
2041
{
2034
2042
TimeRegion TR (Timers ? &Timers->LoadObjectsTimer : nullptr );
0 commit comments