Skip to content

Commit 4086100

Browse files
authored
Merge branch 'main' into main
2 parents 3a6385f + 26e370b commit 4086100

File tree

12 files changed

+340
-66
lines changed

12 files changed

+340
-66
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "clang/AST/DeclObjC.h"
2727
#include "clang/AST/DeclTemplate.h"
2828
#include "clang/AST/Expr.h"
29-
#include "clang/AST/LambdaCapture.h"
3029
#include "clang/AST/RecordLayout.h"
3130
#include "clang/AST/RecursiveASTVisitor.h"
3231
#include "clang/AST/VTableBuilder.h"
@@ -1904,59 +1903,46 @@ CGDebugInfo::createInlinedSubprogram(StringRef FuncName,
19041903
return SP;
19051904
}
19061905

1907-
llvm::StringRef
1908-
CGDebugInfo::GetLambdaCaptureName(const LambdaCapture &Capture) {
1909-
if (Capture.capturesThis())
1910-
return CGM.getCodeGenOpts().EmitCodeView ? "__this" : "this";
1911-
1912-
assert(Capture.capturesVariable());
1913-
1914-
const ValueDecl *CaptureDecl = Capture.getCapturedVar();
1915-
assert(CaptureDecl && "Expected valid decl for captured variable.");
1916-
1917-
return CaptureDecl->getName();
1918-
}
1919-
19201906
void CGDebugInfo::CollectRecordLambdaFields(
19211907
const CXXRecordDecl *CXXDecl, SmallVectorImpl<llvm::Metadata *> &elements,
19221908
llvm::DIType *RecordTy) {
19231909
// For C++11 Lambdas a Field will be the same as a Capture, but the Capture
19241910
// has the name and the location of the variable so we should iterate over
19251911
// both concurrently.
1912+
const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(CXXDecl);
19261913
RecordDecl::field_iterator Field = CXXDecl->field_begin();
19271914
unsigned fieldno = 0;
19281915
for (CXXRecordDecl::capture_const_iterator I = CXXDecl->captures_begin(),
19291916
E = CXXDecl->captures_end();
19301917
I != E; ++I, ++Field, ++fieldno) {
1931-
const LambdaCapture &Capture = *I;
1932-
const uint64_t FieldOffset =
1933-
CGM.getContext().getASTRecordLayout(CXXDecl).getFieldOffset(fieldno);
1934-
1935-
assert(!Field->isBitField() && "lambdas don't have bitfield members!");
1936-
1937-
SourceLocation Loc;
1938-
uint32_t Align = 0;
1939-
1940-
if (Capture.capturesThis()) {
1918+
const LambdaCapture &C = *I;
1919+
if (C.capturesVariable()) {
1920+
SourceLocation Loc = C.getLocation();
1921+
assert(!Field->isBitField() && "lambdas don't have bitfield members!");
1922+
ValueDecl *V = C.getCapturedVar();
1923+
StringRef VName = V->getName();
1924+
llvm::DIFile *VUnit = getOrCreateFile(Loc);
1925+
auto Align = getDeclAlignIfRequired(V, CGM.getContext());
1926+
llvm::DIType *FieldType = createFieldType(
1927+
VName, Field->getType(), Loc, Field->getAccess(),
1928+
layout.getFieldOffset(fieldno), Align, VUnit, RecordTy, CXXDecl);
1929+
elements.push_back(FieldType);
1930+
} else if (C.capturesThis()) {
19411931
// TODO: Need to handle 'this' in some way by probably renaming the
19421932
// this of the lambda class and having a field member of 'this' or
19431933
// by using AT_object_pointer for the function and having that be
19441934
// used as 'this' for semantic references.
1945-
Loc = Field->getLocation();
1946-
} else {
1947-
Loc = Capture.getLocation();
1948-
1949-
const ValueDecl *CaptureDecl = Capture.getCapturedVar();
1950-
assert(CaptureDecl && "Expected valid decl for captured variable.");
1951-
1952-
Align = getDeclAlignIfRequired(CaptureDecl, CGM.getContext());
1935+
FieldDecl *f = *Field;
1936+
llvm::DIFile *VUnit = getOrCreateFile(f->getLocation());
1937+
QualType type = f->getType();
1938+
StringRef ThisName =
1939+
CGM.getCodeGenOpts().EmitCodeView ? "__this" : "this";
1940+
llvm::DIType *fieldType = createFieldType(
1941+
ThisName, type, f->getLocation(), f->getAccess(),
1942+
layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
1943+
1944+
elements.push_back(fieldType);
19531945
}
1954-
1955-
llvm::DIFile *VUnit = getOrCreateFile(Loc);
1956-
1957-
elements.push_back(createFieldType(
1958-
GetLambdaCaptureName(Capture), Field->getType(), Loc,
1959-
Field->getAccess(), FieldOffset, Align, VUnit, RecordTy, CXXDecl));
19601946
}
19611947
}
19621948

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ class CGDebugInfo {
397397
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
398398
SmallVectorImpl<llvm::Metadata *> &E,
399399
llvm::DICompositeType *RecordTy);
400-
llvm::StringRef GetLambdaCaptureName(const LambdaCapture &Capture);
401400

402401
/// If the C++ class has vtable info then insert appropriate debug
403402
/// info entry in EltTys vector.

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,8 @@ static llvm::TargetRegionEntryInfo getEntryInfoFromPresumedLoc(
15501550
return std::pair<std::string, uint64_t>(PLoc.getFilename(), PLoc.getLine());
15511551
};
15521552

1553-
return OMPBuilder.getTargetEntryUniqueInfo(FileInfoCallBack, ParentName);
1553+
return OMPBuilder.getTargetEntryUniqueInfo(FileInfoCallBack,
1554+
*CGM.getFileSystem(), ParentName);
15541555
}
15551556

15561557
ConstantAddress CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {

llvm/include/llvm/Analysis/InterestingMemoryOperand.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ class InterestingMemoryOperand {
3232
Value *MaybeEVL;
3333
// The Stride Value, if we're looking at a strided load/store.
3434
Value *MaybeStride;
35+
// The Offset Value, if we're looking at a indexed load/store. The
36+
// offset actually means byte-offset instead of array index.
37+
Value *MaybeByteOffset;
3538

3639
InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
3740
class Type *OpType, MaybeAlign Alignment,
3841
Value *MaybeMask = nullptr,
3942
Value *MaybeEVL = nullptr,
40-
Value *MaybeStride = nullptr)
43+
Value *MaybeStride = nullptr,
44+
Value *MaybeByteOffset = nullptr)
4145
: IsWrite(IsWrite), OpType(OpType), Alignment(Alignment),
42-
MaybeMask(MaybeMask), MaybeEVL(MaybeEVL), MaybeStride(MaybeStride) {
46+
MaybeMask(MaybeMask), MaybeEVL(MaybeEVL), MaybeStride(MaybeStride),
47+
MaybeByteOffset(MaybeByteOffset) {
4348
const DataLayout &DL = I->getDataLayout();
4449
TypeStoreSize = DL.getTypeStoreSizeInBits(OpType);
4550
PtrUse = &I->getOperandUse(OperandNo);

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ class OpenMPIRBuilder {
14061406
/// any.
14071407
LLVM_ABI static TargetRegionEntryInfo
14081408
getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
1409-
StringRef ParentName = "");
1409+
vfs::FileSystem &VFS, StringRef ParentName = "");
14101410

14111411
/// Enum class for the RedctionGen CallBack type to be used.
14121412
enum class ReductionGenCBKind { Clang, MLIR };

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10313,17 +10313,19 @@ void OffloadEntriesInfoManager::getTargetRegionEntryFnName(
1031310313

1031410314
TargetRegionEntryInfo
1031510315
OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
10316+
vfs::FileSystem &VFS,
1031610317
StringRef ParentName) {
1031710318
sys::fs::UniqueID ID(0xdeadf17e, 0);
1031810319
auto FileIDInfo = CallBack();
1031910320
uint64_t FileID = 0;
10320-
std::error_code EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID);
10321-
// If the inode ID could not be determined, create a hash value
10322-
// the current file name and use that as an ID.
10323-
if (EC)
10321+
if (ErrorOr<vfs::Status> Status = VFS.status(std::get<0>(FileIDInfo))) {
10322+
ID = Status->getUniqueID();
10323+
FileID = Status->getUniqueID().getFile();
10324+
} else {
10325+
// If the inode ID could not be determined, create a hash value
10326+
// the current file name and use that as an ID.
1032410327
FileID = hash_value(std::get<0>(FileIDInfo));
10325-
else
10326-
FileID = ID.getFile();
10328+
}
1032710329

1032810330
return TargetRegionEntryInfo(ParentName, ID.getDevice(), FileID,
1032910331
std::get<1>(FileIDInfo));

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,44 @@ bool RISCVTTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst,
27852785
Alignment, Mask, EVL, Stride);
27862786
return true;
27872787
}
2788+
case Intrinsic::riscv_vloxei_mask:
2789+
case Intrinsic::riscv_vluxei_mask:
2790+
case Intrinsic::riscv_vsoxei_mask:
2791+
case Intrinsic::riscv_vsuxei_mask:
2792+
HasMask = true;
2793+
[[fallthrough]];
2794+
case Intrinsic::riscv_vloxei:
2795+
case Intrinsic::riscv_vluxei:
2796+
case Intrinsic::riscv_vsoxei:
2797+
case Intrinsic::riscv_vsuxei: {
2798+
// Intrinsic interface (only listed ordered version):
2799+
// riscv_vloxei(merge, ptr, index, vl)
2800+
// riscv_vloxei_mask(merge, ptr, index, mask, vl, policy)
2801+
// riscv_vsoxei(val, ptr, index, vl)
2802+
// riscv_vsoxei_mask(val, ptr, index, mask, vl, policy)
2803+
bool IsWrite = Inst->getType()->isVoidTy();
2804+
Type *Ty = IsWrite ? Inst->getArgOperand(0)->getType() : Inst->getType();
2805+
const auto *RVVIInfo = RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(IID);
2806+
unsigned VLIndex = RVVIInfo->VLOperand;
2807+
unsigned PtrOperandNo = VLIndex - 2 - HasMask;
2808+
Value *Mask;
2809+
if (HasMask) {
2810+
Mask = Inst->getArgOperand(VLIndex - 1);
2811+
} else {
2812+
// Mask cannot be nullptr here: vector GEP produces <vscale x N x ptr>,
2813+
// and casting that to scalar i64 triggers a vector/scalar mismatch
2814+
// assertion in CreatePointerCast. Use an all-true mask so ASan lowers it
2815+
// via extractelement instead.
2816+
Type *MaskType = Ty->getWithNewType(Type::getInt1Ty(C));
2817+
Mask = ConstantInt::getTrue(MaskType);
2818+
}
2819+
Value *EVL = Inst->getArgOperand(VLIndex);
2820+
Value *OffsetOp = Inst->getArgOperand(PtrOperandNo + 1);
2821+
Info.InterestingOperands.emplace_back(Inst, PtrOperandNo, IsWrite, Ty,
2822+
Align(1), Mask, EVL,
2823+
/* Stride */ nullptr, OffsetOp);
2824+
return true;
2825+
}
27882826
}
27892827
return false;
27902828
}

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,25 @@ void AddressSanitizer::instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis,
17861786
else
17871787
NumInstrumentedReads++;
17881788

1789+
if (O.MaybeByteOffset) {
1790+
Type *Ty = Type::getInt8Ty(*C);
1791+
IRBuilder IB(O.getInsn());
1792+
1793+
Value *OffsetOp = O.MaybeByteOffset;
1794+
if (TargetTriple.isRISCV()) {
1795+
Type *OffsetTy = OffsetOp->getType();
1796+
// RVV indexed loads/stores zero-extend offset operands which are narrower
1797+
// than XLEN to XLEN.
1798+
if (OffsetTy->getScalarType()->getIntegerBitWidth() <
1799+
static_cast<unsigned>(LongSize)) {
1800+
VectorType *OrigType = cast<VectorType>(OffsetTy);
1801+
Type *ExtendTy = VectorType::get(IntptrTy, OrigType);
1802+
OffsetOp = IB.CreateZExt(OffsetOp, ExtendTy);
1803+
}
1804+
}
1805+
Addr = IB.CreateGEP(Ty, Addr, {OffsetOp});
1806+
}
1807+
17891808
unsigned Granularity = 1 << Mapping.Scale;
17901809
if (O.MaybeMask) {
17911810
instrumentMaskedLoadOrStore(this, DL, IntptrTy, O.MaybeMask, O.MaybeEVL,

0 commit comments

Comments
 (0)