Skip to content

Commit 7f77c7b

Browse files
iclsrcpremanandrao
authored andcommitted
Merge from 'main' to 'sycl-web' (10 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGCall.cpp
2 parents 35977fa + 342e28f commit 7f77c7b

File tree

124 files changed

+1849
-762
lines changed

Some content is hidden

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

124 files changed

+1849
-762
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "llvm/IR/Attributes.h"
4040
#include "llvm/IR/CallingConv.h"
4141
#include "llvm/IR/DataLayout.h"
42+
#include "llvm/IR/DebugInfoMetadata.h"
4243
#include "llvm/IR/FPAccuracy.h"
4344
#include "llvm/IR/InlineAsm.h"
4445
#include "llvm/IR/IntrinsicInst.h"
@@ -6465,6 +6466,24 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
64656466
pushDestroy(QualType::DK_nontrivial_c_struct, Ret.getAggregateAddress(),
64666467
RetTy);
64676468

6469+
// Generate function declaration DISuprogram in order to be used
6470+
// in debug info about call sites.
6471+
if (CGDebugInfo *DI = getDebugInfo()) {
6472+
// Ensure call site info would actually be emitted before collecting
6473+
// further callee info.
6474+
if (CalleeDecl && !CalleeDecl->hasAttr<NoDebugAttr>() &&
6475+
DI->getCallSiteRelatedAttrs() != llvm::DINode::FlagZero) {
6476+
CodeGenFunction CalleeCGF(CGM);
6477+
const GlobalDecl &CalleeGlobalDecl =
6478+
Callee.getAbstractInfo().getCalleeDecl();
6479+
CalleeCGF.CurGD = CalleeGlobalDecl;
6480+
FunctionArgList Args;
6481+
QualType ResTy = CalleeCGF.BuildFunctionArgList(CalleeGlobalDecl, Args);
6482+
DI->EmitFuncDeclForCallSite(
6483+
CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
6484+
}
6485+
}
6486+
64686487
return Ret;
64696488
}
64706489

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4968,7 +4968,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
49684968

49694969
void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
49704970
QualType CalleeType,
4971-
const FunctionDecl *CalleeDecl) {
4971+
GlobalDecl CalleeGlobalDecl) {
49724972
if (!CallOrInvoke)
49734973
return;
49744974
auto *Func = dyn_cast<llvm::Function>(CallOrInvoke->getCalledOperand());
@@ -4977,6 +4977,9 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
49774977
if (Func->getSubprogram())
49784978
return;
49794979

4980+
const FunctionDecl *CalleeDecl =
4981+
cast<FunctionDecl>(CalleeGlobalDecl.getDecl());
4982+
49804983
// Do not emit a declaration subprogram for a function with nodebug
49814984
// attribute, or if call site info isn't required.
49824985
if (CalleeDecl->hasAttr<NoDebugAttr>() ||
@@ -4988,7 +4991,8 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
49884991
// create the one describing the function in order to have complete
49894992
// call site debug info.
49904993
if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
4991-
EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
4994+
EmitFunctionDecl(CalleeGlobalDecl, CalleeDecl->getLocation(), CalleeType,
4995+
Func);
49924996
}
49934997

49944998
void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ class CGDebugInfo {
516516
/// This is needed for call site debug info.
517517
void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
518518
QualType CalleeType,
519-
const FunctionDecl *CalleeDecl);
519+
GlobalDecl CalleeGlobalDecl);
520520

521521
/// Constructs the debug code for exiting a function.
522522
void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
@@ -683,6 +683,10 @@ class CGDebugInfo {
683683
/// Emit symbol for debugger that holds the pointer to the vtable.
684684
void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD);
685685

686+
/// Return flags which enable debug info emission for call sites, provided
687+
/// that it is supported and enabled.
688+
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
689+
686690
private:
687691
/// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
688692
/// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
@@ -832,11 +836,6 @@ class CGDebugInfo {
832836
unsigned LineNo, StringRef LinkageName,
833837
llvm::GlobalVariable *Var, llvm::DIScope *DContext);
834838

835-
836-
/// Return flags which enable debug info emission for call sites, provided
837-
/// that it is supported and enabled.
838-
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
839-
840839
/// Get the printing policy for producing names for debug info.
841840
PrintingPolicy getPrintingPolicy() const;
842841

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6679,15 +6679,6 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
66796679
E == MustTailCall, E->getExprLoc());
66806680

66816681
if (auto *CalleeDecl = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
6682-
// Generate function declaration DISuprogram in order to be used
6683-
// in debug info about call sites.
6684-
if (CGDebugInfo *DI = getDebugInfo()) {
6685-
FunctionArgList Args;
6686-
QualType ResTy = BuildFunctionArgList(CalleeDecl, Args);
6687-
DI->EmitFuncDeclForCallSite(LocalCallOrInvoke,
6688-
DI->getFunctionType(CalleeDecl, ResTy, Args),
6689-
CalleeDecl);
6690-
}
66916682
if (CalleeDecl->hasAttr<RestrictAttr>() ||
66926683
CalleeDecl->hasAttr<AllocSizeAttr>()) {
66936684
// Function has 'malloc' (aka. 'restrict') or 'alloc_size' attribute.

clang/test/C/C2y/n3348.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic %s
2+
3+
/* WG14 N3348: No
4+
* Matching of Multi-Dimensional Arrays in Generic Selection Expressions
5+
*
6+
* This allows use of * in a _Generic association as a placeholder for any size
7+
* value.
8+
*
9+
* FIXME: Clang doesn't yet implement this paper. When we do implement it, we
10+
* should expose the functionality in earlier language modes (C89) for
11+
* compatibility with GCC.
12+
*/
13+
14+
void test(int n, int m) {
15+
static_assert(1 == _Generic(int[3][2], int[3][*]: 1, int[2][*]: 0)); /* expected-error {{star modifier used outside of function prototype}}
16+
expected-error {{array has incomplete element type 'int[]'}}
17+
*/
18+
static_assert(1 == _Generic(int[3][2], int[*][2]: 1, int[*][3]: 0)); // expected-error {{star modifier used outside of function prototype}}
19+
static_assert(1 == _Generic(int[3][n], int[3][*]: 1, int[2][*]: 0)); /* expected-error {{star modifier used outside of function prototype}}
20+
expected-error {{array has incomplete element type 'int[]'}}
21+
*/
22+
static_assert(1 == _Generic(int[n][m], int[*][*]: 1, char[*][*]: 0)); /* expected-error 2 {{star modifier used outside of function prototype}}
23+
expected-error {{array has incomplete element type 'int[]'}}
24+
*/
25+
static_assert(1 == _Generic(int(*)[2], int(*)[*]: 1)); // expected-error {{star modifier used outside of function prototype}}
26+
}
27+
28+
void questionable() {
29+
// GCC accepts this despite the * appearing outside of a generic association,
30+
// but it's not clear whether that's intentionally supported or an oversight.
31+
// It gives a warning about * being used outside of a declaration, but not
32+
// with an associated warning group.
33+
static_assert(1 == _Generic(int[*][*], int[2][100]: 1)); /* expected-error 2 {{star modifier used outside of function prototype}}
34+
expected-error {{array has incomplete element type 'int[]'}}
35+
*/
36+
// GCC claims this matches multiple associations, so the functionality seems
37+
// like it may be intended to work?
38+
(void)_Generic(int[*][*], /* expected-error 2 {{star modifier used outside of function prototype}}
39+
expected-error {{array has incomplete element type 'int[]'}}
40+
*/
41+
int[2][100]: 1,
42+
int[3][1000]: 2,
43+
);
44+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -O1 -triple x86_64-unknown_unknown -emit-llvm \
2+
// RUN: -debug-info-kind=standalone -dwarf-version=5 %s -o - | FileCheck %s
3+
4+
// Ensure both nonmember and member calls to declared function
5+
// have attached `DISubprogram`s.
6+
7+
int nonmember(int n);
8+
9+
struct S {
10+
int x;
11+
int member(int n);
12+
};
13+
14+
int main(int argc, char** argv) {
15+
struct S s = {};
16+
int a = s.member(argc);
17+
int b = nonmember(argc);
18+
return a + b;
19+
}
20+
21+
// CHECK: declare !dbg ![[SP1:[0-9]+]] noundef i32 @_ZN1S6memberEi(
22+
// CHECK: declare !dbg ![[SP2:[0-9]+]] noundef i32 @_Z9nonmemberi(
23+
24+
// CHECK: ![[SP1]] = !DISubprogram(name: "member", linkageName: "_ZN1S6memberEi"
25+
// CHECK: ![[SP2]] = !DISubprogram(name: "nonmember", linkageName: "_Z9nonmemberi"

clang/www/c_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ <h2 id="c2y">C2y implementation status</h2>
324324
<tr>
325325
<td>Matching of Multi-Dimensional Arrays in Generic Selection Expressions</td>
326326
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3348.pdf">N3348</a></td>
327-
<td class="unknown" align="center">Unknown</td>
327+
<td class="none" align="center">No</td>
328328
</tr>
329329
<tr>
330330
<td>The __COUNTER__ predefined macro</td>

libcxx/include/__locale_dir/money.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ bool money_get<_CharT, _InputIterator>::__do_get(
433433
__err |= ios_base::failbit;
434434
return false;
435435
}
436-
for (++__b; __fd > 0; --__fd, ++__b) {
436+
for (++__b; __fd > 0; --__fd, (void)++__b) {
437437
if (__b == __e || !__ct.is(ctype_base::digit, *__b)) {
438438
__err |= ios_base::failbit;
439439
return false;
@@ -451,7 +451,7 @@ bool money_get<_CharT, _InputIterator>::__do_get(
451451
}
452452
}
453453
if (__trailing_sign) {
454-
for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) {
454+
for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, (void)++__b) {
455455
if (__b == __e || *__b != (*__trailing_sign)[__i]) {
456456
__err |= ios_base::failbit;
457457
return false;

libcxx/include/__locale_dir/num.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef _LIBCPP___LOCALE_DIR_NUM_H
1010
#define _LIBCPP___LOCALE_DIR_NUM_H
1111

12+
#include <__algorithm/copy.h>
1213
#include <__algorithm/find.h>
1314
#include <__algorithm/reverse.h>
1415
#include <__charconv/to_chars_integral.h>
@@ -885,9 +886,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty
885886
const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc());
886887
typedef typename numpunct<char_type>::string_type string_type;
887888
string_type __nm = __v ? __np.truename() : __np.falsename();
888-
for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s)
889-
*__s = *__i;
890-
return __s;
889+
return std::copy(__nm.begin(), __nm.end(), __s);
891890
}
892891

893892
template <class _CharT, class _OutputIterator>

libcxx/include/__locale_dir/pad_and_output.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#if _LIBCPP_HAS_LOCALIZATION
1515

16+
# include <__algorithm/copy.h>
17+
# include <__algorithm/fill_n.h>
1618
# include <ios>
1719

1820
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -30,12 +32,9 @@ _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output(
3032
__ns -= __sz;
3133
else
3234
__ns = 0;
33-
for (; __ob < __op; ++__ob, ++__s)
34-
*__s = *__ob;
35-
for (; __ns; --__ns, ++__s)
36-
*__s = __fl;
37-
for (; __ob < __oe; ++__ob, ++__s)
38-
*__s = *__ob;
35+
__s = std::copy(__ob, __op, __s);
36+
__s = std::fill_n(__s, __ns, __fl);
37+
__s = std::copy(__op, __oe, __s);
3938
__iob.width(0);
4039
return __s;
4140
}

0 commit comments

Comments
 (0)