https://github.com/kovdan01 created 
https://github.com/llvm/llvm-project/pull/82364

Currently, for x86 and x86_64 triples, "+sse" and "+sse2" are appended to 
`Features` vector of `TargetOptions` unconditionally. This vector is later 
reset in `TargetInfo::CreateTargetInfo` and filled using info from 
`FeaturesAsWritten` vector, so previous modifications of the `Features` vector 
have no effect. For x86_64 triple, we append "sse2" unconditionally in 
`X86TargetInfo::initFeatureMap`, so despite the `Features` vector reset, we 
still have the desired sse features enabled. The corresponding code in 
`X86TargetInfo::initFeatureMap` is marked as FIXME, so we should not probably 
rely on it and should set desired features properly in `ClangExpressionParser`.

This patch changes the vector the features are appended to from `Features` to 
`FeaturesAsWritten`. It's not reset later and is used to compute resulting 
`Features` vector.

>From 0b7e2f905687995a710dad6fc8da5bea602e39f1 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkova...@accesssoftek.com>
Date: Mon, 19 Feb 2024 17:19:36 +0300
Subject: [PATCH] [lldb][X86] Fix settings target features in
 ClangExpressionParser

Currently, for x86 and x86_64 triples, "+sse" and "+sse2" are appended
to `Features` vector of `TargetOptions` unconditionally. This vector is
later reset in `TargetInfo::CreateTargetInfo` and filled using info from
`FeaturesAsWritten` vector, so previous modifications of the `Features`
vector have no effect. For x86_64 triple, we append "sse2"
unconditionally in `X86TargetInfo::initFeatureMap`, so despite the
`Features` vector reset, we still have the desired sse features enabled.
The corresponding code in `X86TargetInfo::initFeatureMap` is marked as
FIXME, so we should not probably rely on it and should set desired
features properly in `ClangExpressionParser`.

This patch changes the vector the features are appended to from
`Features` to `FeaturesAsWritten`. It's not reset later and is used to
compute resulting `Features` vector.
---
 .../Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 574d661e2a215e..822d286cd6c3c4 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -445,8 +445,8 @@ ClangExpressionParser::ClangExpressionParser(
   // Supported subsets of x86
   if (target_machine == llvm::Triple::x86 ||
       target_machine == llvm::Triple::x86_64) {
-    m_compiler->getTargetOpts().Features.push_back("+sse");
-    m_compiler->getTargetOpts().Features.push_back("+sse2");
+    m_compiler->getTargetOpts().FeaturesAsWritten.push_back("+sse");
+    m_compiler->getTargetOpts().FeaturesAsWritten.push_back("+sse2");
   }
 
   // Set the target CPU to generate code for. This will be empty for any CPU

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to