Skip to content

Commit c769118

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:a5a2a5a3eca0 into amd-gfx:6731da8f7a30
Local branch amd-gfx 6731da8 Merged main:74724902ba2f into amd-gfx:d73ca634171d Remote branch main a5a2a5a [lldb][NFCI] Remove use of ConstString in StructuredData
2 parents 6731da8 + a5a2a5a commit c769118

File tree

182 files changed

+995
-816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+995
-816
lines changed

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ class DataflowAnalysisContext {
108108
/// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.
109109
PointerValue &getOrCreateNullPointerValue(QualType PointeeType);
110110

111+
/// Adds `Constraint` to current and future flow conditions in this context.
112+
///
113+
/// Invariants must contain only flow-insensitive information, i.e. facts that
114+
/// are true on all paths through the program.
115+
/// Information can be added eagerly (when analysis begins), or lazily (e.g.
116+
/// when values are first used). The analysis must be careful that the same
117+
/// information is added regardless of which order blocks are analyzed in.
118+
void addInvariant(const Formula &Constraint);
119+
111120
/// Adds `Constraint` to the flow condition identified by `Token`.
112121
void addFlowConditionConstraint(Atom Token, const Formula &Constraint);
113122

@@ -174,12 +183,11 @@ class DataflowAnalysisContext {
174183
void addModeledFields(const FieldSet &Fields);
175184

176185
/// Adds all constraints of the flow condition identified by `Token` and all
177-
/// of its transitive dependencies to `Constraints`. `VisitedTokens` is used
178-
/// to track tokens of flow conditions that were already visited by recursive
179-
/// calls.
180-
void addTransitiveFlowConditionConstraints(
181-
Atom Token, llvm::SetVector<const Formula *> &Constraints,
182-
llvm::DenseSet<Atom> &VisitedTokens);
186+
/// of its transitive dependencies to `Constraints`.
187+
void
188+
addTransitiveFlowConditionConstraints(Atom Token,
189+
llvm::SetVector<const Formula *> &Out);
190+
183191

184192
/// Returns true if the solver is able to prove that there is no satisfying
185193
/// assignment for `Constraints`
@@ -224,6 +232,7 @@ class DataflowAnalysisContext {
224232
// dependencies is stored in the `FlowConditionDeps` map.
225233
llvm::DenseMap<Atom, llvm::DenseSet<Atom>> FlowConditionDeps;
226234
llvm::DenseMap<Atom, const Formula *> FlowConditionConstraints;
235+
const Formula *Invariant = nullptr;
227236

228237
llvm::DenseMap<const FunctionDecl *, ControlFlowContext> FunctionContexts;
229238

clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
104104
return *Res.first->second;
105105
}
106106

107+
void DataflowAnalysisContext::addInvariant(const Formula &Constraint) {
108+
if (Invariant == nullptr)
109+
Invariant = &Constraint;
110+
else
111+
Invariant = &arena().makeAnd(*Invariant, Constraint);
112+
}
113+
107114
void DataflowAnalysisContext::addFlowConditionConstraint(
108115
Atom Token, const Formula &Constraint) {
109116
auto Res = FlowConditionConstraints.try_emplace(Token, &Constraint);
@@ -149,8 +156,7 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
149156
llvm::SetVector<const Formula *> Constraints;
150157
Constraints.insert(&arena().makeAtomRef(Token));
151158
Constraints.insert(&arena().makeNot(Val));
152-
llvm::DenseSet<Atom> VisitedTokens;
153-
addTransitiveFlowConditionConstraints(Token, Constraints, VisitedTokens);
159+
addTransitiveFlowConditionConstraints(Token, Constraints);
154160
return isUnsatisfiable(std::move(Constraints));
155161
}
156162

@@ -159,8 +165,7 @@ bool DataflowAnalysisContext::flowConditionIsTautology(Atom Token) {
159165
// ever be false.
160166
llvm::SetVector<const Formula *> Constraints;
161167
Constraints.insert(&arena().makeNot(arena().makeAtomRef(Token)));
162-
llvm::DenseSet<Atom> VisitedTokens;
163-
addTransitiveFlowConditionConstraints(Token, Constraints, VisitedTokens);
168+
addTransitiveFlowConditionConstraints(Token, Constraints);
164169
return isUnsatisfiable(std::move(Constraints));
165170
}
166171

@@ -172,37 +177,41 @@ bool DataflowAnalysisContext::equivalentFormulas(const Formula &Val1,
172177
}
173178

174179
void DataflowAnalysisContext::addTransitiveFlowConditionConstraints(
175-
Atom Token, llvm::SetVector<const Formula *> &Constraints,
176-
llvm::DenseSet<Atom> &VisitedTokens) {
177-
auto Res = VisitedTokens.insert(Token);
178-
if (!Res.second)
179-
return;
180-
181-
auto ConstraintsIt = FlowConditionConstraints.find(Token);
182-
if (ConstraintsIt == FlowConditionConstraints.end()) {
183-
Constraints.insert(&arena().makeAtomRef(Token));
184-
} else {
185-
// Bind flow condition token via `iff` to its set of constraints:
186-
// FC <=> (C1 ^ C2 ^ ...), where Ci are constraints
187-
Constraints.insert(&arena().makeEquals(arena().makeAtomRef(Token),
188-
*ConstraintsIt->second));
189-
}
190-
191-
auto DepsIt = FlowConditionDeps.find(Token);
192-
if (DepsIt != FlowConditionDeps.end()) {
193-
for (Atom DepToken : DepsIt->second) {
194-
addTransitiveFlowConditionConstraints(DepToken, Constraints,
195-
VisitedTokens);
180+
Atom Token, llvm::SetVector<const Formula *> &Constraints) {
181+
llvm::DenseSet<Atom> AddedTokens;
182+
std::vector<Atom> Remaining = {Token};
183+
184+
if (Invariant)
185+
Constraints.insert(Invariant);
186+
// Define all the flow conditions that might be referenced in constraints.
187+
while (!Remaining.empty()) {
188+
auto Token = Remaining.back();
189+
Remaining.pop_back();
190+
if (!AddedTokens.insert(Token).second)
191+
continue;
192+
193+
auto ConstraintsIt = FlowConditionConstraints.find(Token);
194+
if (ConstraintsIt == FlowConditionConstraints.end()) {
195+
Constraints.insert(&arena().makeAtomRef(Token));
196+
} else {
197+
// Bind flow condition token via `iff` to its set of constraints:
198+
// FC <=> (C1 ^ C2 ^ ...), where Ci are constraints
199+
Constraints.insert(&arena().makeEquals(arena().makeAtomRef(Token),
200+
*ConstraintsIt->second));
196201
}
202+
203+
if (auto DepsIt = FlowConditionDeps.find(Token);
204+
DepsIt != FlowConditionDeps.end())
205+
for (Atom A : DepsIt->second)
206+
Remaining.push_back(A);
197207
}
198208
}
199209

200210
void DataflowAnalysisContext::dumpFlowCondition(Atom Token,
201211
llvm::raw_ostream &OS) {
202212
llvm::SetVector<const Formula *> Constraints;
203213
Constraints.insert(&arena().makeAtomRef(Token));
204-
llvm::DenseSet<Atom> VisitedTokens;
205-
addTransitiveFlowConditionConstraints(Token, Constraints, VisitedTokens);
214+
addTransitiveFlowConditionConstraints(Token, Constraints);
206215

207216
// TODO: have formulas know about true/false directly instead
208217
Atom True = arena().makeLiteral(true).getAtom();

clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ TEST_F(DataflowAnalysisContextTest, AddFlowConditionConstraint) {
4646
EXPECT_TRUE(Context.flowConditionImplies(FC, C));
4747
}
4848

49+
TEST_F(DataflowAnalysisContextTest, AddInvariant) {
50+
Atom FC = A.makeFlowConditionToken();
51+
auto &C = A.makeAtomRef(A.makeAtom());
52+
Context.addInvariant(C);
53+
EXPECT_TRUE(Context.flowConditionImplies(FC, C));
54+
}
55+
56+
TEST_F(DataflowAnalysisContextTest, InvariantAndFCConstraintInteract) {
57+
Atom FC = A.makeFlowConditionToken();
58+
auto &C = A.makeAtomRef(A.makeAtom());
59+
auto &D = A.makeAtomRef(A.makeAtom());
60+
Context.addInvariant(A.makeImplies(C, D));
61+
Context.addFlowConditionConstraint(FC, C);
62+
EXPECT_TRUE(Context.flowConditionImplies(FC, D));
63+
}
64+
4965
TEST_F(DataflowAnalysisContextTest, ForkFlowCondition) {
5066
Atom FC1 = A.makeFlowConditionToken();
5167
auto &C1 = A.makeAtomRef(A.makeAtom());

clang/www/c_status.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,11 +917,6 @@ <h2 id="c2x">C23 implementation status</h2>
917917
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2688.pdf">N2686</a></td>
918918
<td class="full" align="center">Yes</td>
919919
</tr>
920-
<tr>
921-
<td>Integer constant expressions</td>
922-
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2713.htm">N2713</a></td>
923-
<td class="none" align="center">No</td>
924-
</tr>
925920
<tr>
926921
<td>Numerically equal</td>
927922
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2716.htm">N2716</a></td>

cross-project-tests/debuginfo-tests/dexter-tests/aggregate-indirect-arg.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
//
54
// RUN: %clang -std=gnu++11 -O0 -g -lstdc++ %s -o %t
65
// RUN: %dexter --fail-lt 1.0 -w \

cross-project-tests/debuginfo-tests/dexter-tests/ctor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
//
54
// RUN: %clang -std=gnu++11 -O0 -glldb %s -o %t
65
// RUN: %dexter --fail-lt 1.0 -w \

cross-project-tests/debuginfo-tests/dexter-tests/dbg-arg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
//
54
// This test case checks debug info during register moves for an argument.
65
// RUN: %clang -std=gnu11 -m64 -mllvm -fast-isel=false -g %s -o %t

cross-project-tests/debuginfo-tests/dexter-tests/deferred_globals.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// REQUIRES: lldb
66
// UNSUPPORTED: system-windows
7-
// XFAIL: system-darwin
87
// RUN: %clang -std=gnu++11 -O0 -g %s -o %t
98
// RUN: %dexter --fail-lt 1.0 -w \
109
// RUN: --binary %t --debugger 'lldb' -v -- %s

cross-project-tests/debuginfo-tests/dexter-tests/memvars/ctrl-flow.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
// RUN: %clang -std=gnu11 -O2 -glldb %s -o %t
54
// RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s
65

cross-project-tests/debuginfo-tests/dexter-tests/memvars/inlining.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
// RUN: %clang -std=gnu11 -O2 -glldb %s -o %t
54
// RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s
65
//

cross-project-tests/debuginfo-tests/dexter-tests/namespace.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// REQUIRES: lldb
66
// UNSUPPORTED: system-windows
7-
// XFAIL: system-darwin
87

98
// RUN: %clang -g -O0 %s -o %t
109
// RUN: %dexter --fail-lt 1.0 -w \

cross-project-tests/debuginfo-tests/dexter-tests/stack-var.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// REQUIRES: lldb
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
//
54
// RUN: %clang -std=gnu11 -O -glldb %s -o %t
65
// RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'lldb' -- %s

cross-project-tests/debuginfo-tests/dexter-tests/vla.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This test case verifies the debug location for variable-length arrays.
22
// REQUIRES: lldb
33
// UNSUPPORTED: system-windows
4-
// XFAIL: system-darwin
54
//
65
// RUN: %clang -std=gnu11 -O0 -glldb %s -o %t
76
// RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'lldb' -- %s

cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/DefaultController.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ def _run_debugger_custom(self, cmdline):
8787
self.step_collection.debugger = self.debugger.debugger_info
8888
self._break_point_all_lines()
8989
self.debugger.launch(cmdline)
90-
9190
for command_obj in chain.from_iterable(self.step_collection.commands.values()):
9291
self.watches.update(command_obj.get_watches())
9392
early_exit_conditions = self._get_early_exit_conditions()
94-
9593
timed_out = False
9694
total_timeout = Timeout(self.context.options.timeout_total)
9795
max_steps = self.context.options.max_steps

cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def run_debugger_subprocess(debugger_controller, working_dir_path):
226226

227227
with open(controller_path, "rb") as fp:
228228
debugger_controller = pickle.load(fp)
229-
230229
return debugger_controller
231230

232231

cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,34 @@ def delete_breakpoints(self, ids):
174174
self._target.BreakpointDelete(id)
175175

176176
def launch(self, cmdline):
177+
num_resolved_breakpoints = 0
178+
for b in self._target.breakpoint_iter():
179+
num_resolved_breakpoints += b.GetNumLocations() > 0
180+
assert num_resolved_breakpoints > 0
181+
177182
if self.context.options.target_run_args:
178183
cmdline += shlex.split(self.context.options.target_run_args)
179-
self._process = self._target.LaunchSimple(cmdline, None, os.getcwd())
184+
launch_info = self._target.GetLaunchInfo()
185+
launch_info.SetWorkingDirectory(os.getcwd())
186+
launch_info.SetArguments(cmdline, True)
187+
error = self._interface.SBError()
188+
self._process = self._target.Launch(launch_info, error)
189+
190+
if error.Fail():
191+
raise DebuggerException(error.GetCString())
192+
if not os.path.exists(self._target.executable.fullpath):
193+
raise DebuggerException("exe does not exist")
180194
if not self._process or self._process.GetNumThreads() == 0:
181195
raise DebuggerException("could not launch process")
182196
if self._process.GetNumThreads() != 1:
183197
raise DebuggerException("multiple threads not supported")
184198
self._thread = self._process.GetThreadAtIndex(0)
199+
200+
num_stopped_threads = 0
201+
for thread in self._process:
202+
if thread.GetStopReason() == self._interface.eStopReasonBreakpoint:
203+
num_stopped_threads += 1
204+
assert num_stopped_threads > 0
185205
assert self._thread, (self._process, self._thread)
186206

187207
def step(self):

cross-project-tests/debuginfo-tests/dexter/dex/tools/Main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ def __init__(self):
193193

194194
def main() -> ReturnCode:
195195
context = Context()
196-
197196
with PrettyOutput() as context.o:
198197
context.logger = Logger(context.o)
199198
try:

cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import csv
1212
import pickle
1313
import shutil
14+
import platform
1415

1516
from dex.command.ParseCommand import get_command_infos
1617
from dex.debugger.Debuggers import run_debugger_subprocess
@@ -217,6 +218,9 @@ def _run_test(self, test_name):
217218
"""
218219
try:
219220
if self.context.options.binary:
221+
if platform.system() == 'Darwin' and os.path.exists(self.context.options.binary + '.dSYM'):
222+
# On Darwin, the debug info is in the .dSYM which might not be found by lldb, copy it into the tmp working directory
223+
shutil.copytree(self.context.options.binary + '.dSYM', self.context.options.executable + '.dSYM')
220224
# Copy user's binary into the tmp working directory.
221225
shutil.copy(
222226
self.context.options.binary, self.context.options.executable

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/command_line.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// The dbgeng driver doesn't support \DexCommandLine yet.
22
// UNSUPPORTED: system-windows
3-
// XFAIL: system-darwin
43
//
54
// RUN: %dexter_regression_test_build %s -o %t
65
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/address_after_ref.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that a \DexDeclareAddress value can have its value defined after
33
// the first reference to that value.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: address_after_ref.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/address_hit_count.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// expression after the target line has been stepped on a given number of
55
// times.
66
//
7-
// XFAIL: system-darwin
87
// RUN: %dexter_regression_test_build %s -o %t
98
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
109
// CHECK: address_hit_count.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/expression_address.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that a \DexDeclareAddress value can be used to compare the
33
// addresses of two local variables that refer to the same address.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: expression_address.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/identical_address.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that a \DexDeclareAddress value can be used to compare two equal
33
// pointer variables.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: identical_address.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/multiple_address.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that multiple \DexDeclareAddress references that point to different
33
// addresses can be used within a single \DexExpectWatchValue.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: multiple_address.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/offset_address.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that a \DexDeclareAddress value can be used to compare two pointer
33
// variables that have a fixed offset between them.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: offset_address.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_declare_address/self_comparison.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that a \DexDeclareAddress value can be used to check the change in
33
// value of a variable over time, relative to its initial value.
44
//
5-
// XFAIL: system-darwin
65
// RUN: %dexter_regression_test_build %s -o %t
76
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
87
// CHECK: self_comparison.cpp

cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// condition (x == 5) is satisfied.
77
// Tests using the default controller (no \DexLimitSteps).
88
//
9-
// XFAIL: system-darwin
109
// RUN: %dexter_regression_test_build %s -o %t
1110
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
1211
// CHECK: default_conditional.cpp

0 commit comments

Comments
 (0)