Skip to content

Commit d13271c

Browse files
Merge branch 'main' into qual-wg-backlog-update
2 parents 02ca373 + 1956941 commit d13271c

File tree

34 files changed

+872
-524
lines changed

34 files changed

+872
-524
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
942942
if (!Result)
943943
return false;
944944
if (DiscardResult)
945-
return this->emitPop(*T, BO);
945+
return this->emitPopBool(BO);
946946
if (T != PT_Bool)
947947
return this->emitCast(PT_Bool, *T, BO);
948948
return true;

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
182182
mlir::Value VisitBinDivAssign(const CompoundAssignOperator *e) {
183183
return emitCompoundAssign(e, &ComplexExprEmitter::emitBinDiv);
184184
}
185+
186+
mlir::Value VisitVAArgExpr(VAArgExpr *e);
185187
};
186188
} // namespace
187189

@@ -597,6 +599,10 @@ mlir::Value ComplexExprEmitter::VisitUnaryNot(const UnaryOperator *e) {
597599
return builder.createNot(op);
598600
}
599601

602+
mlir::Value ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *e) {
603+
return cgf.emitVAArg(e);
604+
}
605+
600606
mlir::Value ComplexExprEmitter::emitPromoted(const Expr *e,
601607
QualType promotionTy) {
602608
e = e->IgnoreParens();

clang/test/AST/ByteCode/c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,9 @@ void bar() { // pedantic-warning {{a function declaration without a prototype}}
362362
int x;
363363
x = foo(); // all-warning {{too few arguments}}
364364
}
365+
366+
int *_b = &a;
367+
void discardedCmp(void)
368+
{
369+
(*_b) = ((&a == &a) , a); // all-warning {{left operand of comma operator has no effect}}
370+
}

clang/test/AST/ByteCode/vectors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both -flax-vector-conversions=none %s
2-
// RUN: %clang_cc1 -verify=ref,both -flax-vector-conversions=none %s
1+
// RUN: %clang_cc1 -Wno-c++20-extensions -fexperimental-new-constant-interpreter -verify=expected,both -flax-vector-conversions=none %s
2+
// RUN: %clang_cc1 -Wno-c++20-extensions -verify=ref,both -flax-vector-conversions=none %s
33

44
typedef int __attribute__((vector_size(16))) VI4;
55
constexpr VI4 A = {1,2,3,4};
@@ -147,7 +147,7 @@ namespace {
147147
namespace Assign {
148148
constexpr int a2() {
149149
VI a = {0, 0, 0, 0};
150-
VI b; // both-warning {{C++20 extension}}
150+
VI b;
151151

152152
b = {1,1,1,1};
153153
return b[0] + b[1] + b[2] + b[3];
@@ -161,7 +161,7 @@ namespace Assign {
161161

162162
constexpr bool invalid() {
163163
v2int16_t a = {0, 0};
164-
v2int_t b; // both-warning {{C++20 extension}}
164+
v2int_t b;
165165
b = a; // both-error {{incompatible type}}
166166

167167
return true;

clang/test/CIR/CodeGen/complex.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,3 +853,59 @@ void foo32() {
853853
// OGCG: %[[REAL_ADDR:.*]] = alloca i32, align 4
854854
// OGCG: %[[REAL:.*]] = load i32, ptr @_ZN9Container1cE, align 4
855855
// OGCG: store i32 %[[REAL]], ptr %[[REAL_ADDR]], align 4
856+
857+
void foo33(__builtin_va_list a) {
858+
float _Complex b = __builtin_va_arg(a, float _Complex);
859+
}
860+
861+
// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.ptr<!rec___va_list_tag>, !cir.ptr<!cir.ptr<!rec___va_list_tag>>, ["a", init]
862+
// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["b", init]
863+
// CIR: cir.store %[[ARG_0:.*]], %[[A_ADDR]] : !cir.ptr<!rec___va_list_tag>, !cir.ptr<!cir.ptr<!rec___va_list_tag>>
864+
// CIR: %[[VA_TAG:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.ptr<!rec___va_list_tag>>, !cir.ptr<!rec___va_list_tag>
865+
// CIR: %[[COMPLEX:.*]] = cir.va_arg %[[VA_TAG]] : (!cir.ptr<!rec___va_list_tag>) -> !cir.complex<!cir.float>
866+
// CIR: cir.store{{.*}} %[[COMPLEX]], %[[B_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
867+
868+
// LLVM: %[[A_ADDR:.*]] = alloca ptr, i64 1, align 8
869+
// LLVM: %[[B_ADDR:.*]] = alloca { float, float }, i64 1, align 4
870+
// LLVM: store ptr %[[ARG_0:.*]], ptr %[[A_ADDR]], align 8
871+
// LLVM: %[[TMP_A:.*]] = load ptr, ptr %[[A_ADDR]], align 8
872+
// LLVM: %[[COMPLEX:.*]] = va_arg ptr %[[TMP_A]], { float, float }
873+
// LLVM: store { float, float } %[[COMPLEX]], ptr %[[B_ADDR]], align 4
874+
875+
// TODO(CIR): the difference between the CIR LLVM and OGCG is because the lack of calling convention lowering,
876+
// Test will be updated when that is implemented
877+
878+
// OGCG: %[[A_ADDR:.*]] = alloca ptr, align 8
879+
// OGCG: %[[B_ADDR:.*]] = alloca { float, float }, align 4
880+
// OGCG: store ptr %[[ARG_0:.*]], ptr %[[A_ADDR]], align 8
881+
// OGCG: %[[TMP_A:.*]] = load ptr, ptr %[[A_ADDR]], align 8
882+
// OGCG: %[[GP_OFFSET_PTR:.*]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[TMP_A]], i32 0, i32 1
883+
// OGCG: %[[GP_OFFSET:.*]] = load i32, ptr %[[GP_OFFSET_PTR]], align 4
884+
// OGCG: %[[COND:.*]] = icmp ule i32 %[[GP_OFFSET]], 160
885+
// OGCG: br i1 %[[COND]], label %[[VA_ARG_IN_REG:.*]], label %[[VA_ARG_IN_MEM:.*]]
886+
//
887+
// OGCG: [[VA_ARG_IN_REG]]:
888+
// OGCG: %[[REG_SAVE_PTR:.*]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[TMP_A]], i32 0, i32 3
889+
// OGCG: %[[REG_SAVE:.*]] = load ptr, ptr %[[REG_SAVE_PTR]], align 8
890+
// OGCG: %[[VA_ADDR:..*]] = getelementptr i8, ptr %[[REG_SAVE]], i32 %[[GP_OFFSET]]
891+
// OGCG: %[[GP_OFFSET_NEXT:.*]] = add i32 %[[GP_OFFSET]], 16
892+
// OGCG: store i32 %[[GP_OFFSET_NEXT]], ptr %[[GP_OFFSET_PTR]], align 4
893+
// OGCG: br label %[[VA_ARG_END:.*]]
894+
//
895+
// OGCG: [[VA_ARG_IN_MEM]]:
896+
// OGCG: %[[OVERFLOW_PTR:.*]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[TMP_A]], i32 0, i32 2
897+
// OGCG: %[[OVERFLOW:.*]] = load ptr, ptr %[[OVERFLOW_PTR]], align 8
898+
// OGCG: %[[OVERFLOW_NEXT:.*]] = getelementptr i8, ptr %[[OVERFLOW]], i32 8
899+
// OGCG: store ptr %[[OVERFLOW_NEXT]], ptr %[[OVERFLOW_PTR]], align 8
900+
// OGCG: br label %[[VA_ARG_END]]
901+
//
902+
// OGCG: [[VA_ARG_END]]:
903+
// OGCG: %[[RESULT:.*]] = phi ptr [ %[[VA_ADDR]], %[[VA_ARG_IN_REG]] ], [ %[[OVERFLOW]], %[[VA_ARG_IN_MEM]] ]
904+
// OGCG: %[[RESULT_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[RESULT]], i32 0, i32 0
905+
// OGCG: %[[RESULT_REAL:.*]] = load float, ptr %[[RESULT_REAL_PTR]], align 4
906+
// OGCG: %[[RESULT_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[RESULT]], i32 0, i32 1
907+
// OGCG: %[[RESULT_IMAG:.*]] = load float, ptr %[[RESULT_IMAG_PTR]], align 4
908+
// OGCG: %[[B_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[B_ADDR]], i32 0, i32 0
909+
// OGCG: %[[B_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[B_ADDR]], i32 0, i32 1
910+
// OGCG: store float %[[RESULT_REAL]], ptr %[[B_REAL_PTR]], align 4
911+
// OGCG: store float %[[RESULT_IMAG]], ptr %[[B_IMAG_PTR]], align 4

compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
// RUN: %clang_cl_asan %Od %MT -o %t %s
22
// RUN: %env_asan_opts=windows_hook_rtl_allocators=true %run %t 2>&1 | FileCheck %s
3-
// UNSUPPORTED: asan-64-bits
43
#include <cassert>
54
#include <iostream>
5+
#include <sanitizer/allocator_interface.h>
66
#include <windows.h>
77

88
int main() {
99
void *ptr = malloc(0);
1010
if (ptr)
1111
std::cerr << "allocated!\n";
12-
((char *)ptr)[0] = '\xff'; //check this 'allocate 1 instead of 0' hack hasn't changed
12+
13+
// Check the 'allocate 1 instead of 0' hack hasn't changed
14+
// Note that as of b3452d90b043a398639e62b0ab01aa339cc649de, dereferencing
15+
// the pointer will be detected as a heap-buffer-overflow.
16+
if (__sanitizer_get_allocated_size(ptr) != 1)
17+
return 1;
1318

1419
free(ptr);
1520

flang/lib/Optimizer/Transforms/AffinePromotion.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "mlir/IR/BuiltinAttributes.h"
2626
#include "mlir/IR/IntegerSet.h"
2727
#include "mlir/IR/Visitors.h"
28-
#include "mlir/Transforms/DialectConversion.h"
28+
#include "mlir/Transforms/WalkPatternRewriteDriver.h"
2929
#include "llvm/ADT/DenseMap.h"
3030
#include "llvm/Support/Debug.h"
3131
#include <optional>
@@ -451,10 +451,10 @@ static void rewriteStore(fir::StoreOp storeOp,
451451
}
452452

453453
static void rewriteMemoryOps(Block *block, mlir::PatternRewriter &rewriter) {
454-
for (auto &bodyOp : block->getOperations()) {
454+
for (auto &bodyOp : llvm::make_early_inc_range(block->getOperations())) {
455455
if (isa<fir::LoadOp>(bodyOp))
456456
rewriteLoad(cast<fir::LoadOp>(bodyOp), rewriter);
457-
if (isa<fir::StoreOp>(bodyOp))
457+
else if (isa<fir::StoreOp>(bodyOp))
458458
rewriteStore(cast<fir::StoreOp>(bodyOp), rewriter);
459459
}
460460
}
@@ -476,6 +476,8 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
476476
loop.dump(););
477477
LLVM_ATTRIBUTE_UNUSED auto loopAnalysis =
478478
functionAnalysis.getChildLoopAnalysis(loop);
479+
if (!loopAnalysis.canPromoteToAffine())
480+
return rewriter.notifyMatchFailure(loop, "cannot promote to affine");
479481
auto &loopOps = loop.getBody()->getOperations();
480482
auto resultOp = cast<fir::ResultOp>(loop.getBody()->getTerminator());
481483
auto results = resultOp.getOperands();
@@ -576,12 +578,14 @@ class AffineIfConversion : public mlir::OpRewritePattern<fir::IfOp> {
576578
public:
577579
using OpRewritePattern::OpRewritePattern;
578580
AffineIfConversion(mlir::MLIRContext *context, AffineFunctionAnalysis &afa)
579-
: OpRewritePattern(context) {}
581+
: OpRewritePattern(context), functionAnalysis(afa) {}
580582
llvm::LogicalResult
581583
matchAndRewrite(fir::IfOp op,
582584
mlir::PatternRewriter &rewriter) const override {
583585
LLVM_DEBUG(llvm::dbgs() << "AffineIfConversion: rewriting if:\n";
584586
op.dump(););
587+
if (!functionAnalysis.getChildIfAnalysis(op).canPromoteToAffine())
588+
return rewriter.notifyMatchFailure(op, "cannot promote to affine");
585589
auto &ifOps = op.getThenRegion().front().getOperations();
586590
auto affineCondition = AffineIfCondition(op.getCondition());
587591
if (!affineCondition.hasIntegerSet()) {
@@ -611,6 +615,8 @@ class AffineIfConversion : public mlir::OpRewritePattern<fir::IfOp> {
611615
rewriter.replaceOp(op, affineIf.getOperation()->getResults());
612616
return success();
613617
}
618+
619+
AffineFunctionAnalysis &functionAnalysis;
614620
};
615621

616622
/// Promote fir.do_loop and fir.if to affine.for and affine.if, in the cases
@@ -627,28 +633,11 @@ class AffineDialectPromotion
627633
mlir::RewritePatternSet patterns(context);
628634
patterns.insert<AffineIfConversion>(context, functionAnalysis);
629635
patterns.insert<AffineLoopConversion>(context, functionAnalysis);
630-
mlir::ConversionTarget target = *context;
631-
target.addLegalDialect<mlir::affine::AffineDialect, FIROpsDialect,
632-
mlir::scf::SCFDialect, mlir::arith::ArithDialect,
633-
mlir::func::FuncDialect>();
634-
target.addDynamicallyLegalOp<IfOp>([&functionAnalysis](fir::IfOp op) {
635-
return !(functionAnalysis.getChildIfAnalysis(op).canPromoteToAffine());
636-
});
637-
target.addDynamicallyLegalOp<DoLoopOp>([&functionAnalysis](
638-
fir::DoLoopOp op) {
639-
return !(functionAnalysis.getChildLoopAnalysis(op).canPromoteToAffine());
640-
});
641-
642636
LLVM_DEBUG(llvm::dbgs()
643637
<< "AffineDialectPromotion: running promotion on: \n";
644638
function.print(llvm::dbgs()););
645639
// apply the patterns
646-
if (mlir::failed(mlir::applyPartialConversion(function, target,
647-
std::move(patterns)))) {
648-
mlir::emitError(mlir::UnknownLoc::get(context),
649-
"error in converting to affine dialect\n");
650-
signalPassFailure();
651-
}
640+
walkAndApplyPatterns(function, std::move(patterns));
652641
}
653642
};
654643
} // namespace

lldb/include/lldb/Core/Disassembler.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,26 @@ class Disassembler : public std::enable_shared_from_this<Disassembler>,
566566
const Disassembler &operator=(const Disassembler &) = delete;
567567
};
568568

569+
/// Tracks live variable annotations across instructions and produces
570+
/// per-instruction "events" like `name = RDI` or `name = <undef>`.
571+
class VariableAnnotator {
572+
struct VarState {
573+
/// Display name.
574+
std::string name;
575+
/// Last printed location (empty means <undef>).
576+
std::string last_loc;
577+
};
578+
579+
// Live state from the previous instruction, keyed by Variable::GetID().
580+
llvm::DenseMap<lldb::user_id_t, VarState> Live_;
581+
582+
public:
583+
/// Compute annotation strings for a single instruction and update `Live_`.
584+
/// Returns only the events that should be printed *at this instruction*.
585+
std::vector<std::string> annotate(Instruction &inst, Target &target,
586+
const lldb::ModuleSP &module_sp);
587+
};
588+
569589
} // namespace lldb_private
570590

571591
#endif // LLDB_CORE_DISASSEMBLER_H

0 commit comments

Comments
 (0)