Skip to content

Commit 8356cb5

Browse files
authored
merge main into amd-staging (llvm#1347)
2 parents 28d6079 + 8fc23ff commit 8356cb5

File tree

200 files changed

+3156
-5974
lines changed

Some content is hidden

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

200 files changed

+3156
-5974
lines changed

bolt/test/indirect-goto-relocs.test

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@
44
RUN: %clang %cflags -pie %S/Inputs/indirect_goto.c -o %t.exe -Wl,-q
55
RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-PIE %s
66

7-
RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -o %t.exe -Wl,-q
8-
RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-NO-PIE %s
9-
107
// Check that BOLT registers extra entry points for dynamic relocations with PIE.
118
CHECK-PIE: Binary Function "main" after building cfg {
129
CHECK-PIE: IsMultiEntry: 1
1310
CHECK-PIE: Secondary Entry Points : {{.*}}
14-
15-
// Check that BOLT does not register extra entry points for dynamic relocations
16-
// without PIE
17-
CHECK-NO-PIE: Binary Function "main" after building cfg {
18-
CHECK-NO-PIE-NOT: IsMultiEntry: 1
19-
CHECK-NO-PIE-NOT: Secondary Entry Points : {{.*}}

clang/docs/analyzer/checkers.rst

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,41 @@ core.DivideZero (C, C++, ObjC)
9797
.. literalinclude:: checkers/dividezero_example.c
9898
:language: c
9999

100+
.. _core-FixedAddressDereference:
101+
102+
core.FixedAddressDereference (C, C++, ObjC)
103+
"""""""""""""""""""""""""""""""""""""""""""
104+
Check for dereferences of fixed addresses.
105+
106+
A pointer contains a fixed address if it was set to a hard-coded value or it
107+
becomes otherwise obvious that at that point it can have only a single fixed
108+
numerical value.
109+
110+
.. code-block:: c
111+
112+
void test1() {
113+
int *p = (int *)0x020;
114+
int x = p[0]; // warn
115+
}
116+
117+
void test2(int *p) {
118+
if (p == (int *)-1)
119+
*p = 0; // warn
120+
}
121+
122+
void test3() {
123+
int (*p_function)(char, char);
124+
p_function = (int (*)(char, char))0x04080;
125+
int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
126+
}
127+
128+
If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
129+
to true (the default value), then this checker never reports dereference of
130+
pointers with a specified address space. If the option is set to false, then
131+
reports from the specific x86 address spaces 256, 257 and 258 are still
132+
suppressed, but fixed address dereferences from other address spaces are
133+
reported.
134+
100135
.. _core-NonNullParamChecker:
101136

102137
core.NonNullParamChecker (C, C++, ObjC)
@@ -2971,41 +3006,6 @@ Check for assignment of a fixed address to a pointer.
29713006
p = (int *) 0x10000; // warn
29723007
}
29733008
2974-
.. _alpha-core-FixedAddressDereference:
2975-
2976-
alpha.core.FixedAddressDereference (C, C++, ObjC)
2977-
"""""""""""""""""""""""""""""""""""""""""""""""""
2978-
Check for dereferences of fixed addresses.
2979-
2980-
A pointer contains a fixed address if it was set to a hard-coded value or it
2981-
becomes otherwise obvious that at that point it can have only a single specific
2982-
value.
2983-
2984-
.. code-block:: c
2985-
2986-
void test1() {
2987-
int *p = (int *)0x020;
2988-
int x = p[0]; // warn
2989-
}
2990-
2991-
void test2(int *p) {
2992-
if (p == (int *)-1)
2993-
*p = 0; // warn
2994-
}
2995-
2996-
void test3() {
2997-
int (*p_function)(char, char);
2998-
p_function = (int (*)(char, char))0x04080;
2999-
int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
3000-
}
3001-
3002-
If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
3003-
to true (the default value), then this checker never reports dereference of
3004-
pointers with a specified address space. If the option is set to false, then
3005-
reports from the specific x86 address spaces 256, 257 and 258 are still
3006-
suppressed, but fixed address dereferences from other address spaces are
3007-
reported.
3008-
30093009
.. _alpha-core-PointerArithm:
30103010
30113011
alpha.core.PointerArithm (C)

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class ASTWriter : public ASTDeserializationListener,
370370
///
371371
/// Only meaningful for standard C++ named modules. See the comments in
372372
/// createSignatureForNamedModule() for details.
373-
llvm::DenseSet<Module *> TouchedTopLevelModules;
373+
llvm::SetVector<Module *> TouchedTopLevelModules;
374374

375375
/// An update to a Decl.
376376
class DeclUpdate {

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ def DereferenceModeling : Checker<"DereferenceModeling">,
211211
Documentation<NotDocumented>,
212212
Hidden;
213213

214+
def FixedAddressDereferenceChecker
215+
: Checker<"FixedAddressDereference">,
216+
HelpText<"Check for dereferences of fixed addresses">,
217+
Documentation<HasDocumentation>,
218+
Dependencies<[DereferenceModeling]>;
219+
214220
def NullDereferenceChecker : Checker<"NullDereference">,
215221
HelpText<"Check for dereferences of null pointers">,
216222
Documentation<HasDocumentation>,
@@ -278,12 +284,6 @@ def FixedAddressChecker : Checker<"FixedAddr">,
278284
HelpText<"Check for assignment of a fixed address to a pointer">,
279285
Documentation<HasDocumentation>;
280286

281-
def FixedAddressDereferenceChecker
282-
: Checker<"FixedAddressDereference">,
283-
HelpText<"Check for dereferences of fixed addresses">,
284-
Documentation<HasDocumentation>,
285-
Dependencies<[DereferenceModeling]>;
286-
287287
def PointerArithChecker : Checker<"PointerArithm">,
288288
HelpText<"Check for pointer arithmetic on locations other than array "
289289
"elements">,

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,19 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
383383
for (const Pointer *P = Pointers; P; P = P->Next) {
384384
++NPointers;
385385
}
386+
OS << " EvalID: " << EvalID << '\n';
387+
OS << " DeclID: ";
388+
if (DeclID)
389+
OS << *DeclID << '\n';
390+
else
391+
OS << "-\n";
386392
OS << " Pointers: " << NPointers << "\n";
387393
OS << " Dead: " << IsDead << "\n";
388394
OS << " Static: " << IsStatic << "\n";
389395
OS << " Extern: " << IsExtern << "\n";
390396
OS << " Initialized: " << IsInitialized << "\n";
397+
OS << " Weak: " << IsWeak << "\n";
398+
OS << " Dynamic: " << IsDynamic << "\n";
391399
}
392400

393401
LLVM_DUMP_METHOD void EvaluationResult::dump() const {

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,18 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
602602
// In C++14 onwards, it is permitted to read a mutable member whose
603603
// lifetime began within the evaluation.
604604
if (S.getLangOpts().CPlusPlus14 &&
605-
Ptr.block()->getEvalID() == S.Ctx.getEvalID())
605+
Ptr.block()->getEvalID() == S.Ctx.getEvalID()) {
606+
// FIXME: This check is necessary because (of the way) we revisit
607+
// variables in Compiler.cpp:visitDeclRef. Revisiting a so far
608+
// unknown variable will get the same EvalID and we end up allowing
609+
// reads from mutable members of it.
610+
if (!S.inConstantContext()) {
611+
if (const VarDecl *VD = Ptr.block()->getDescriptor()->asVarDecl();
612+
VD && VD->hasLocalStorage())
613+
return false;
614+
}
606615
return true;
616+
}
607617

608618
const SourceInfo &Loc = S.Current->getSource(OpPC);
609619
const FieldDecl *Field = Ptr.getField();

clang/lib/Analysis/FlowSensitive/Transfer.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ static BoolValue &evaluateBooleanEquality(const Expr &LHS, const Expr &RHS,
6060
Value *LHSValue = Env.getValue(LHS);
6161
Value *RHSValue = Env.getValue(RHS);
6262

63-
if (LHSValue == RHSValue)
63+
// When two unsupported values are compared, both are nullptr. Only supported
64+
// values should evaluate to equal.
65+
if (LHSValue == RHSValue && LHSValue)
66+
return Env.getBoolLiteralValue(true);
67+
68+
// Special case: `NullPtrLiteralExpr == itself`. When both sides are untyped
69+
// nullptr, they do not have an assigned Value, but they compare equal.
70+
if (LHS.getType()->isNullPtrType() && RHS.getType()->isNullPtrType())
6471
return Env.getBoolLiteralValue(true);
6572

6673
if (auto *LHSBool = dyn_cast_or_null<BoolValue>(LHSValue))

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,31 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "CGBuiltin.h"
1314
#include "ABIInfo.h"
1415
#include "CGCUDARuntime.h"
1516
#include "CGCXXABI.h"
1617
#include "CGObjCRuntime.h"
1718
#include "CGOpenCLRuntime.h"
1819
#include "CGRecordLayout.h"
1920
#include "CGValue.h"
20-
#include "CGBuiltin.h"
2121
#include "CodeGenFunction.h"
2222
#include "CodeGenModule.h"
2323
#include "ConstantEmitter.h"
2424
#include "PatternInit.h"
2525
#include "TargetInfo.h"
26-
#include "clang/AST/ASTContext.h"
27-
#include "clang/AST/Attr.h"
28-
#include "clang/AST/Decl.h"
29-
#include "clang/AST/Expr.h"
3026
#include "clang/AST/OSLog.h"
31-
#include "clang/AST/OperationKinds.h"
3227
#include "clang/AST/StmtVisitor.h"
33-
#include "clang/AST/Type.h"
3428
#include "clang/Basic/TargetBuiltins.h"
3529
#include "clang/Basic/TargetInfo.h"
3630
#include "clang/Basic/TargetOptions.h"
37-
#include "clang/CodeGen/CGFunctionInfo.h"
3831
#include "clang/Frontend/FrontendDiagnostic.h"
39-
#include "llvm/ADT/APFloat.h"
40-
#include "llvm/ADT/APInt.h"
41-
#include "llvm/ADT/FloatingPointMode.h"
42-
#include "llvm/ADT/SmallPtrSet.h"
43-
#include "llvm/ADT/StringExtras.h"
44-
#include "llvm/Analysis/ValueTracking.h"
45-
#include "llvm/IR/DataLayout.h"
4632
#include "llvm/IR/InlineAsm.h"
4733
#include "llvm/IR/Intrinsics.h"
4834
#include "llvm/IR/IntrinsicsX86.h"
49-
#include "llvm/IR/MDBuilder.h"
5035
#include "llvm/IR/MatrixBuilder.h"
51-
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
5236
#include "llvm/Support/ConvertUTF.h"
53-
#include "llvm/Support/MathExtras.h"
5437
#include "llvm/Support/ScopedPrinter.h"
55-
#include <numeric>
5638
#include <optional>
5739
#include <utility>
5840

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,14 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "ABIInfo.h"
14-
#include "CGHLSLRuntime.h"
1513
#include "CGBuiltin.h"
16-
#include "TargetInfo.h"
14+
#include "CGHLSLRuntime.h"
1715
#include "clang/Basic/TargetBuiltins.h"
18-
#include "llvm/ADT/StringExtras.h"
1916
#include "llvm/Analysis/ValueTracking.h"
20-
#include "llvm/IR/Intrinsics.h"
2117
#include "llvm/IR/IntrinsicsAMDGPU.h"
2218
#include "llvm/IR/IntrinsicsR600.h"
23-
#include "llvm/IR/MDBuilder.h"
24-
#include "llvm/IR/MatrixBuilder.h"
2519
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
2620
#include "llvm/Support/AMDGPUAddrSpace.h"
27-
#include "llvm/Support/ConvertUTF.h"
2821

2922
using namespace clang;
3023
using namespace CodeGen;

clang/lib/CodeGen/TargetBuiltins/ARM.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "TargetInfo.h"
1616
#include "clang/Basic/TargetBuiltins.h"
1717
#include "llvm/IR/InlineAsm.h"
18-
#include "llvm/IR/Intrinsics.h"
1918
#include "llvm/IR/IntrinsicsAArch64.h"
2019
#include "llvm/IR/IntrinsicsARM.h"
2120
#include "llvm/IR/IntrinsicsBPF.h"

0 commit comments

Comments
 (0)