[llvm-branch-commits] [clang] 0f8bcf3 - test commit
Author: Egor Zhdan
Date: 2022-01-07T19:05:57Z
New Revision: 0f8bcf374737cb3bfe88537e7bc740d6ffef3553
URL:
https://github.com/llvm/llvm-project/commit/0f8bcf374737cb3bfe88537e7bc740d6ffef3553
DIFF:
https://github.com/llvm/llvm-project/commit/0f8bcf374737cb3bfe88537e7bc740d6ffef3553.diff
LOG: test commit
Added:
Modified:
clang/lib/Sema/SemaExpr.cpp
Removed:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a2a1f76df96d2..5e6772677efb9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15903,6 +15903,7 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation
BuiltinLoc,
TInfo->getTypeLoc()))
return ExprError();
+
if (!TInfo->getType().isPODType(Context)) {
Diag(TInfo->getTypeLoc().getBeginLoc(),
TInfo->getType()->isObjCLifetimeType()
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 0f915e7 - [RegAllocFast] Fix nondeterminism in debuginfo generation
Author: Ilya Yanok Date: 2022-01-07T11:26:25-08:00 New Revision: 0f915e755eae63df568e62b877dee558b97bbdc2 URL: https://github.com/llvm/llvm-project/commit/0f915e755eae63df568e62b877dee558b97bbdc2 DIFF: https://github.com/llvm/llvm-project/commit/0f915e755eae63df568e62b877dee558b97bbdc2.diff LOG: [RegAllocFast] Fix nondeterminism in debuginfo generation Changes from commit 1db137b1859692ae33228c530d4df9f2431b2151 added iteration over hash map that can result in non-deterministic order. Fix that by using a SmallMapVector to preserve the order. Differential Revision: https://reviews.llvm.org/D113468 (cherry picked from commit 3c47c5ca13b8a502de3272e8105548715947b7a8) Added: Modified: llvm/lib/CodeGen/RegAllocFast.cpp Removed: diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index 707161d5a8b07..68920e2e50df4 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IndexedMap.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SparseSet.h" @@ -432,7 +433,7 @@ void RegAllocFast::spill(MachineBasicBlock::iterator Before, Register VirtReg, // every definition of it, meaning we can switch all the DBG_VALUEs over // to just reference the stack slot. SmallVectorImpl &LRIDbgOperands = LiveDbgValueMap[VirtReg]; - SmallDenseMap> + SmallMapVector, 2> SpilledOperandsMap; for (MachineOperand *MO : LRIDbgOperands) SpilledOperandsMap[MO->getParent()].push_back(MO); ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 35df3f9 - [DIArgList] Re-unique after changing operands to fix non-determinism
Author: Teresa Johnson
Date: 2022-01-07T11:26:33-08:00
New Revision: 35df3f98639eedee2cc61f95add40a2b08276f44
URL:
https://github.com/llvm/llvm-project/commit/35df3f98639eedee2cc61f95add40a2b08276f44
DIFF:
https://github.com/llvm/llvm-project/commit/35df3f98639eedee2cc61f95add40a2b08276f44.diff
LOG: [DIArgList] Re-unique after changing operands to fix non-determinism
We have a large compile showing occasional non-deterministic behavior
that is due to DIArgList not being properly uniqued in some cases. I
tracked this down to handleChangedOperands, for which there is a custom
implementation for DIArgList, that does not take care of re-uniquing
after updating the DIArgList Args, unlike the default version of
handleChangedOperands for MDNode.
Since the Args in the DIArgList form the key for the store, this seems
to be occasionally breaking the lookup in that DenseSet. Specifically,
when invoking DIArgList::get() from replaceVariableLocationOp, very
occasionally it returns a new DIArgList object, when one already exists
having the same exact Args pointers. This in turn causes a subsequent
call to Instruction::isIdenticalToWhenDefined on those two otherwise
identical DIArgList objects during a later pass to return false, leading
to different IR in those rare cases.
I modified DIArgList::handleChangedOperands to perform similar
re-uniquing as the MDNode version used by other metadata node types.
This also necessitated a change to the context destructor, since in some
cases we end up with DIArgList as distinct nodes: DIArgList is the only
metadata node type to have a custom dropAllReferences, so we need to
invoke that version on DIArgList in the DistinctMDNodes store to clean
it up properly.
Differential Revision: https://reviews.llvm.org/D108968
(cherry picked from commit badcd585897253e94b7b2d4e6f9f430a2020d642)
Added:
Modified:
llvm/include/llvm/IR/Metadata.h
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/LLVMContextImpl.cpp
Removed:
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index c5840564454e0..17a9c3a77f4e4 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -897,6 +897,7 @@ struct TempMDNodeDeleter {
class MDNode : public Metadata {
friend class ReplaceableMetadataImpl;
friend class LLVMContextImpl;
+ friend class DIArgList;
unsigned NumOperands;
unsigned NumUnresolved;
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp
b/llvm/lib/IR/DebugInfoMetadata.cpp
index 7b0dab799e1a9..2180eedb58f7c 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -1592,6 +1592,12 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata
*New) {
assert((!New || isa(New)) &&
"DIArgList must be passed a ValueAsMetadata");
untrack();
+ bool Uniq = isUniqued();
+ if (Uniq) {
+// We need to update the uniqueness once the Args are updated since they
+// form the key to the DIArgLists store.
+eraseFromStore();
+ }
ValueAsMetadata *NewVM = cast_or_null(New);
for (ValueAsMetadata *&VM : Args) {
if (&VM == OldVMPtr) {
@@ -1601,6 +1607,10 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata
*New) {
VM = ValueAsMetadata::get(UndefValue::get(VM->getValue()->getType()));
}
}
+ if (Uniq) {
+if (uniquify() != this)
+ storeDistinctInContext();
+ }
track();
}
void DIArgList::track() {
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index 99819602c5452..85ac63eaa1aa9 100644
--- a/llvm/lib/IR/LLVMContextImpl.cpp
+++ b/llvm/lib/IR/LLVMContextImpl.cpp
@@ -55,8 +55,15 @@ LLVMContextImpl::~LLVMContextImpl() {
// Drop references for MDNodes. Do this before Values get deleted to avoid
// unnecessary RAUW when nodes are still unresolved.
- for (auto *I : DistinctMDNodes)
+ for (auto *I : DistinctMDNodes) {
+// We may have DIArgList that were uniqued, and as it has a custom
+// implementation of dropAllReferences, it needs to be explicitly invoked.
+if (auto *AL = dyn_cast(I)) {
+ AL->dropAllReferences();
+ continue;
+}
I->dropAllReferences();
+ }
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)
\
for (auto *I : CLASS##s)
\
I->dropAllReferences();
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 12aaa85 - [InstCombine] Remove attributes after hoisting free above null check
Author: Shoaib Meenai
Date: 2022-01-07T15:16:51-08:00
New Revision: 12aaa8553f82dae682e4bad318a67615f39175ae
URL:
https://github.com/llvm/llvm-project/commit/12aaa8553f82dae682e4bad318a67615f39175ae
DIFF:
https://github.com/llvm/llvm-project/commit/12aaa8553f82dae682e4bad318a67615f39175ae.diff
LOG: [InstCombine] Remove attributes after hoisting free above null check
If the parameter had been annotated as nonnull because of the null
check, we want to remove the attribute, since it may no longer apply and
could result in miscompiles if left. Similarly, we also want to remove
undef-implying attributes, since they may not apply anymore either.
Fixes PR52110.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D111515
(cherry picked from commit 6404f4b5af39840a2dad27abc3924eb3846ae8a4)
Added:
llvm/test/Transforms/InstCombine/malloc-free.ll
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Removed:
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 4e3b18e805ee2..71b3a411cc184 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2843,6 +2843,26 @@ static Instruction *tryToMoveFreeBeforeNullTest(CallInst
&FI,
}
assert(FreeInstrBB->size() == 1 &&
"Only the branch instruction should remain");
+
+ // Now that we've moved the call to free before the NULL check, we have to
+ // remove any attributes on its parameter that imply it's non-null, because
+ // those attributes might have only been valid because of the NULL check, and
+ // we can get miscompiles if we keep them. This is conservative if non-null
is
+ // also implied by something other than the NULL check, but it's guaranteed
to
+ // be correct, and the conservativeness won't matter in practice, since the
+ // attributes are irrelevant for the call to free itself and the pointer
+ // shouldn't be used after the call.
+ AttributeList Attrs = FI.getAttributes();
+ Attrs = Attrs.removeParamAttribute(FI.getContext(), 0, Attribute::NonNull);
+ Attribute Dereferenceable = Attrs.getParamAttr(0,
Attribute::Dereferenceable);
+ if (Dereferenceable.isValid()) {
+uint64_t Bytes = Dereferenceable.getDereferenceableBytes();
+Attrs = Attrs.removeParamAttribute(FI.getContext(), 0,
+ Attribute::Dereferenceable);
+Attrs = Attrs.addDereferenceableOrNullParamAttr(FI.getContext(), 0, Bytes);
+ }
+ FI.setAttributes(Attrs);
+
return &FI;
}
diff --git a/llvm/test/Transforms/InstCombine/malloc-free.ll
b/llvm/test/Transforms/InstCombine/malloc-free.ll
new file mode 100644
index 0..e1168ab71156b
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/malloc-free.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare noalias i8* @calloc(i32, i32) nounwind
+declare noalias i8* @malloc(i32)
+declare noalias i8* @aligned_alloc(i32, i32)
+declare void @free(i8*)
+
+;; Test that nonnull-implying attributes on the parameter are adjusted when the
+;; call is moved, since they may no longer be valid and result in miscompiles
if
+;; kept unchanged.
+define void @test_nonnull_free_move(i8* %foo) minsize {
+; CHECK-LABEL: @test_nonnull_free_move(
+; CHECK-NEXT: entry:
+; CHECK-NEXT:[[TOBOOL:%.*]] = icmp eq i8* [[FOO:%.*]], null
+; CHECK-NEXT:tail call void @free(i8* [[FOO]])
+; CHECK-NEXT:br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT:br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT:ret void
+;
+entry:
+ %tobool = icmp eq i8* %foo, null
+ br i1 %tobool, label %if.end, label %if.then
+
+if.then: ; preds = %entry
+ tail call void @free(i8* nonnull %foo)
+ br label %if.end
+
+if.end: ; preds = %entry, %if.then
+ ret void
+}
+
+define void @test_dereferenceable_free_move(i8* %foo) minsize {
+; CHECK-LABEL: @test_dereferenceable_free_move(
+; CHECK-NEXT: entry:
+; CHECK-NEXT:[[TOBOOL:%.*]] = icmp eq i8* [[FOO:%.*]], null
+; CHECK-NEXT:tail call void @free(i8* dereferenceable_or_null(4) [[FOO]])
+; CHECK-NEXT:br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT:br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT:ret void
+;
+entry:
+ %tobool = icmp eq i8* %foo, null
+ br i1 %tobool, label %if.end, label %if.then
+
+if.then: ; preds = %entry
+ tail call void @free(i8* dereferenceable(4) %foo)
+ br label %if.end
+
+if.end: ; preds = %entry, %if.then
+ ret void
+}
+
+defin
[llvm-branch-commits] [clang] 1ac6bb3 - [Clang][CFG] check children statements of asm goto
Author: Nick Desaulniers
Date: 2022-01-07T20:55:42-08:00
New Revision: 1ac6bb3c4dd48f9135ccae0425b1d04f85b460cc
URL:
https://github.com/llvm/llvm-project/commit/1ac6bb3c4dd48f9135ccae0425b1d04f85b460cc
DIFF:
https://github.com/llvm/llvm-project/commit/1ac6bb3c4dd48f9135ccae0425b1d04f85b460cc.diff
LOG: [Clang][CFG] check children statements of asm goto
When performing CFG based analyses, don't forget to check the child
statements of an asm goto, such as the expressions used for
inputs+outputs.
Fixes: https://github.com/llvm/llvm-project/issues/51024
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1439
Reviewed By: void, jyknight, jyu2, efriedma
Differential Revision: https://reviews.llvm.org/D116059
(cherry picked from commit 3a604fdbcd5fd9ca41f6659692bb4ad2151c3cf4)
Added:
Modified:
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/test/Analysis/asm-goto.cpp
clang/test/Analysis/uninit-asm-goto.cpp
clang/test/Sema/array-bounds-ptr-arith.c
Removed:
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 0805642824c07..87c2f6f9f08ff 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3361,7 +3361,7 @@ CFGBlock *CFGBuilder::VisitGCCAsmStmt(GCCAsmStmt *G,
AddStmtChoice asc) {
// Save "Succ" in BackpatchBlocks. In the backpatch processing, "Succ" is
// used to avoid adding "Succ" again.
BackpatchBlocks.push_back(JumpSource(Succ, ScopePos));
- return Block;
+ return VisitChildren(G);
}
CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
diff --git a/clang/lib/Analysis/UninitializedValues.cpp
b/clang/lib/Analysis/UninitializedValues.cpp
index a38ae34f4b811..811146e50b45a 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -819,12 +819,11 @@ void TransferFunctions::VisitGCCAsmStmt(GCCAsmStmt *as) {
while (const auto *UO = dyn_cast(Ex))
Ex = stripCasts(C, UO->getSubExpr());
+// Mark the variable as potentially uninitialized for those cases where
+// it's used on an indirect path, where it's not guaranteed to be
+// defined.
if (const VarDecl *VD = findVar(Ex).getDecl())
- if (vals[VD] != Initialized)
-// If the variable isn't initialized by the time we get here, then we
-// mark it as potentially uninitialized for those cases where it's used
-// on an indirect path, where it's not guaranteed to be defined.
-vals[VD] = MayUninitialized;
+ vals[VD] = MayUninitialized;
}
}
diff --git a/clang/test/Analysis/asm-goto.cpp
b/clang/test/Analysis/asm-goto.cpp
index bc212f800401a..75f907a209b2d 100644
--- a/clang/test/Analysis/asm-goto.cpp
+++ b/clang/test/Analysis/asm-goto.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-pc-linux-gnu
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
-// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -triple i386-pc-linux-gnu
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
int foo(int cond)
{
@@ -17,11 +17,12 @@ int foo(int cond)
// CHECK-NEXT: Succs (1): B0
// CHECK-LABEL: label_true
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: cond
+// CHECK-NEXT: [B3.1]
+// CHECK-NEXT: T: asm goto
// CHECK-NEXT: Preds (2): B3 B4
// CHECK-NEXT: Succs (3): B2 B3 B1
-
int bar(int cond)
{
asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::L1, L2);
@@ -32,7 +33,9 @@ int bar(int cond)
}
// CHECK: [B4]
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: cond
+// CHECK-NEXT: [B4.1]
+// CHECK-NEXT: T: asm goto
// CHECK-NEXT: Preds (1): B5
// CHECK-NEXT: Succs (3): B3 B2 B1
@@ -48,6 +51,20 @@ int zoo(int n)
}
// CHECK-LABEL: A1
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: n
+// CHECK-NEXT: [B4.1]
+// CHECK-NEXT: T: asm goto
// CHECK-NEXT: Preds (2): B5 B4
// CHECK-NEXT: Succs (5): B3 B4 B2 B1 B5
+
+void baz(void)
+{
+ asm goto("" :: "r"(1 ? 2 : 0 << -1) :: error);
+error:;
+}
+
+// CHECK: [B2]
+// CHECK-NEXT: 1: [B5.2] ? [B3.1] : [B4.4]
+// CHECK-NEXT: T: asm goto ("" : : "r" ([B2.1]) : : error);
+// CHECK-NEXT: Preds (2): B3 B4
+// CHECK-NEXT: Succs (1): B1
diff --git a/clang/test/Analysis/uninit-asm-goto.cpp
b/clang/test/Analysis/uninit-asm-goto.cpp
index 9da21584ec864..1b9d1689b036f 100644
--- a/clang/test/Analysis/uninit-asm-goto.cpp
+++ b/clang/test/Analysis/uninit-asm-goto.cpp
@@ -3,19 +3,19 @@
// test1: Expect no diagnostics
int test1(int x) {
int y;
-asm goto("nop" : "=r"(y) : "r"(x) : : err);
+asm goto("" : "=r"(y) : "r"(x) : : err);
return y;
err:
return -1;
}
int test2(int x) {
- int y; // expected-warning {{variable 'y' is used uninitialized whenever its
declaration is reached}}
[llvm-branch-commits] [clang] bfb1bd1 - [Clang][Sema] Avoid crashing for va_arg expressions with bool argument
Author: Egor Zhdan
Date: 2022-01-07T23:57:55-08:00
New Revision: bfb1bd1b9906356c747ac480bc44230790c87cb1
URL:
https://github.com/llvm/llvm-project/commit/bfb1bd1b9906356c747ac480bc44230790c87cb1
DIFF:
https://github.com/llvm/llvm-project/commit/bfb1bd1b9906356c747ac480bc44230790c87cb1.diff
LOG: [Clang][Sema] Avoid crashing for va_arg expressions with bool argument
This change fixes a compiler crash that was introduced in
https://reviews.llvm.org/D103611: `Sema::BuildVAArgExpr` attempted to retrieve
a corresponding signed type for `bool` by calling
`ASTContext::getCorrespondingSignedType`.
rdar://86580370
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D116272
(cherry picked from commit c033f0d9b1c7816b0488a939475d48a100e4dcab)
Added:
Modified:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/varargs.cpp
Removed:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f04eb91990244..4179249e91de5 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15868,7 +15868,7 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation
BuiltinLoc,
// promoted type and the underlying type are the same except for
// signedness. Ask the AST for the correctly corresponding type and see
// if that's compatible.
- if (!PromoteType.isNull() &&
+ if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
PromoteType->isUnsignedIntegerType() !=
UnderlyingType->isUnsignedIntegerType()) {
UnderlyingType =
diff --git a/clang/test/SemaCXX/varargs.cpp b/clang/test/SemaCXX/varargs.cpp
index 7bec2f1e63030..bc2fe89a6ff8d 100644
--- a/clang/test/SemaCXX/varargs.cpp
+++ b/clang/test/SemaCXX/varargs.cpp
@@ -53,6 +53,8 @@ void promotable(int a, ...) {
// Ensure that signed vs unsigned doesn't matter either.
(void)__builtin_va_arg(ap, unsigned int);
+
+ (void)__builtin_va_arg(ap, bool); // expected-warning {{second argument to
'va_arg' is of promotable type 'bool'; this va_arg has undefined behavior
because arguments will be promoted to 'int'}}
}
#if __cplusplus >= 201103L
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
