Skip to content

Commit c3f9f30

Browse files
more debug code
Created using spr 1.3.6
2 parents f04adce + 0659044 commit c3f9f30

Some content is hidden

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

44 files changed

+890
-474
lines changed

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ struct MissingFeatures {
2727
// Address space related
2828
static bool addressSpace() { return false; }
2929

30-
// CIRGenFunction implementation details
31-
static bool cgfSymbolTable() { return false; }
32-
3330
// Unhandled global/linkage information.
3431
static bool opGlobalThreadLocal() { return false; }
3532
static bool opGlobalConstant() { return false; }

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,12 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) {
591591
? emitLoadOfReferenceLValue(addr, getLoc(e->getSourceRange()),
592592
vd->getType(), AlignmentSource::Decl)
593593
: makeAddrLValue(addr, ty, AlignmentSource::Decl);
594+
595+
// Statics are defined as globals, so they are not include in the function's
596+
// symbol table.
597+
assert((vd->isStaticLocal() || symbolTable.count(vd)) &&
598+
"non-static locals should be already mapped");
599+
594600
return lv;
595601
}
596602

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
215215
mlir::Location loc, CharUnits alignment,
216216
bool isParam) {
217217
assert(isa<NamedDecl>(var) && "Needs a named decl");
218-
assert(!cir::MissingFeatures::cgfSymbolTable());
218+
assert(!symbolTable.count(var) && "not supposed to be available just yet");
219219

220220
auto allocaOp = addrVal.getDefiningOp<cir::AllocaOp>();
221221
assert(allocaOp && "expected cir::AllocaOp");
@@ -224,6 +224,8 @@ void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
224224
allocaOp.setInitAttr(mlir::UnitAttr::get(&getMLIRContext()));
225225
if (ty->isReferenceType() || ty.isConstQualified())
226226
allocaOp.setConstantAttr(mlir::UnitAttr::get(&getMLIRContext()));
227+
228+
symbolTable.insert(var, allocaOp);
227229
}
228230

229231
void CIRGenFunction::LexicalScope::cleanup() {
@@ -485,6 +487,9 @@ void CIRGenFunction::finishFunction(SourceLocation endLoc) {
485487
}
486488

487489
mlir::LogicalResult CIRGenFunction::emitFunctionBody(const clang::Stmt *body) {
490+
// We start with function level scope for variables.
491+
SymTableScopeTy varScope(symbolTable);
492+
488493
auto result = mlir::LogicalResult::success();
489494
if (const CompoundStmt *block = dyn_cast<CompoundStmt>(body))
490495
emitCompoundStmtWithoutScope(*block);
@@ -531,6 +536,8 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn,
531536
FunctionArgList args;
532537
QualType retTy = buildFunctionArgList(gd, args);
533538

539+
// Create a scope in the symbol table to hold variable declarations.
540+
SymTableScopeTy varScope(symbolTable);
534541
{
535542
LexicalScope lexScope(*this, fusedLoc, entryBB);
536543

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "clang/CIR/Dialect/IR/CIRDialect.h"
3232
#include "clang/CIR/MissingFeatures.h"
3333
#include "clang/CIR/TypeEvaluationKind.h"
34+
#include "llvm/ADT/ScopedHashTable.h"
3435

3536
namespace {
3637
class ScalarExprEmitter;
@@ -103,6 +104,14 @@ class CIRGenFunction : public CIRGenTypeCache {
103104
/// Sanitizers enabled for this function.
104105
clang::SanitizerSet sanOpts;
105106

107+
/// The symbol table maps a variable name to a value in the current scope.
108+
/// Entering a function creates a new scope, and the function arguments are
109+
/// added to the mapping. When the processing of a function is terminated,
110+
/// the scope is destroyed and the mappings created in this scope are
111+
/// dropped.
112+
using SymTableTy = llvm::ScopedHashTable<const clang::Decl *, mlir::Value>;
113+
SymTableTy symbolTable;
114+
106115
/// Whether or not a Microsoft-style asm block has been processed within
107116
/// this fuction. These can potentially set the return value.
108117
bool sawAsmBlock = false;
@@ -325,6 +334,9 @@ class CIRGenFunction : public CIRGenTypeCache {
325334
~SourceLocRAIIObject() { restore(); }
326335
};
327336

337+
using SymTableScopeTy =
338+
llvm::ScopedHashTableScope<const clang::Decl *, mlir::Value>;
339+
328340
/// Hold counters for incrementally naming temporaries
329341
unsigned counterRefTmp = 0;
330342
unsigned counterAggTmp = 0;
@@ -499,7 +511,11 @@ class CIRGenFunction : public CIRGenTypeCache {
499511
void setAddrOfLocalVar(const clang::VarDecl *vd, Address addr) {
500512
assert(!localDeclMap.count(vd) && "Decl already exists in LocalDeclMap!");
501513
localDeclMap.insert({vd, addr});
502-
// TODO: Add symbol table support
514+
515+
// Add to the symbol table if not there already.
516+
if (symbolTable.count(vd))
517+
return;
518+
symbolTable.insert(vd, addr.getPointer());
503519
}
504520

505521
bool shouldNullCheckClassCastValue(const CastExpr *ce);

clang/lib/CIR/CodeGen/CIRGenStmt.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ void CIRGenFunction::emitCompoundStmtWithoutScope(const CompoundStmt &s) {
3333
}
3434

3535
void CIRGenFunction::emitCompoundStmt(const CompoundStmt &s) {
36+
// Add local scope to track new declared variables.
37+
SymTableScopeTy varScope(symbolTable);
3638
mlir::Location scopeLoc = getLoc(s.getSourceRange());
3739
mlir::OpBuilder::InsertPoint scopeInsPt;
3840
builder.create<cir::ScopeOp>(

clang/test/Sema/attr-cfi-salt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s
1+
// RUN: %clang_cc1 -std=c11 -fsyntax-only -fsanitize=kcfi -verify %s
22
// RUN: %clang_cc1 -std=c89 -DKNR -fsyntax-only -fsanitize=kcfi -verify %s
33

44
#define __cfi_salt(S) __attribute__((cfi_salt(S)))

flang/module/cudadevice.f90

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -625,57 +625,57 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
625625
end function
626626
end interface
627627

628-
interface __double2ll_rn
629-
attributes(device) integer(8) function __double2ll_rn(r) bind(c)
628+
interface __double2ll_rd
629+
attributes(device) integer(8) function __double2ll_rd(r) bind(c, name='__nv_double2ll_rd')
630630
!dir$ ignore_tkr (d) r
631631
double precision, value :: r
632632
end function
633633
end interface
634634

635-
interface __double2ll_rz
636-
attributes(device) integer(8) function __double2ll_rz(r) bind(c)
635+
interface __double2ll_rn
636+
attributes(device) integer(8) function __double2ll_rn(r) bind(c, name='__nv_double2ll_rn')
637637
!dir$ ignore_tkr (d) r
638638
double precision, value :: r
639639
end function
640640
end interface
641641

642642
interface __double2ll_ru
643-
attributes(device) integer(8) function __double2ll_ru(r) bind(c)
643+
attributes(device) integer(8) function __double2ll_ru(r) bind(c, name='__nv_double2ll_ru')
644644
!dir$ ignore_tkr (d) r
645645
double precision, value :: r
646646
end function
647647
end interface
648648

649-
interface __double2ll_rd
650-
attributes(device) integer(8) function __double2ll_rd(r) bind(c)
649+
interface __double2ll_rz
650+
attributes(device) integer(8) function __double2ll_rz(r) bind(c, name='__nv_double2ll_rz')
651651
!dir$ ignore_tkr (d) r
652652
double precision, value :: r
653653
end function
654654
end interface
655655

656-
interface __double2ull_rn
657-
attributes(device) integer(8) function __double2ull_rn(r) bind(c)
656+
interface __double2ull_rd
657+
attributes(device) integer(8) function __double2ull_rd(r) bind(c, name='__nv_double2ull_rd')
658658
!dir$ ignore_tkr (d) r
659659
double precision, value :: r
660660
end function
661661
end interface
662662

663-
interface __double2ull_rz
664-
attributes(device) integer(8) function __double2ull_rz(r) bind(c)
663+
interface __double2ull_rn
664+
attributes(device) integer(8) function __double2ull_rn(r) bind(c, name='__nv_double2ull_rn')
665665
!dir$ ignore_tkr (d) r
666666
double precision, value :: r
667667
end function
668668
end interface
669669

670670
interface __double2ull_ru
671-
attributes(device) integer(8) function __double2ull_ru(r) bind(c)
671+
attributes(device) integer(8) function __double2ull_ru(r) bind(c, name='__nv_double2ull_ru')
672672
!dir$ ignore_tkr (d) r
673673
double precision, value :: r
674674
end function
675675
end interface
676676

677-
interface __double2ull_rd
678-
attributes(device) integer(8) function __double2ull_rd(r) bind(c)
677+
interface __double2ull_rz
678+
attributes(device) integer(8) function __double2ull_rz(r) bind(c, name='__nv_double2ull_rz')
679679
!dir$ ignore_tkr (d) r
680680
double precision, value :: r
681681
end function

flang/test/Lower/CUDA/cuda-libdevice.cuf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,33 @@ end subroutine
100100
! CHECK-LABEL: _QPtest_exp
101101
! CHECK: %{{.*}} = fir.call @__nv_expf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
102102
! CHECK: %{{.*}} = fir.call @__nv_exp10f(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
103+
104+
attributes(global) subroutine test_double2ll_rX()
105+
integer(8) :: res
106+
double precision :: r
107+
res = __double2ll_rd(r)
108+
res = __double2ll_rn(r)
109+
res = __double2ll_ru(r)
110+
res = __double2ll_rz(r)
111+
end subroutine
112+
113+
! CHECK-LABEL: _QPtest_double2ll_rx
114+
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
115+
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
116+
! CHECK: %{{.*}} = fir.call @__nv_double2ll_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
117+
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
118+
119+
attributes(global) subroutine test_double2ull_rX()
120+
integer(8) :: res
121+
double precision :: r
122+
res = __double2ull_rd(r)
123+
res = __double2ull_rn(r)
124+
res = __double2ull_ru(r)
125+
res = __double2ull_rz(r)
126+
end subroutine
127+
128+
! CHECK-LABEL: _QPtest_double2ull_rx
129+
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
130+
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
131+
! CHECK: %{{.*}} = fir.call @__nv_double2ull_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
132+
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in
6868
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
6969
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
7070
option(LLDB_ENABLE_PROTOCOL_SERVERS "Enable protocol servers (e.g. MCP) in LLDB" ON)
71-
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)" OFF)
7271
option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF)
7372
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF)
7473
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing lldb." OFF)
@@ -174,11 +173,20 @@ if (LLDB_ENABLE_PYTHON)
174173
${default_embed_python_home})
175174

176175
include_directories(${Python3_INCLUDE_DIRS})
176+
177177
if (LLDB_EMBED_PYTHON_HOME)
178178
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
179179
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
180180
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
181181
endif()
182+
183+
if (SWIG_VERSION VERSION_GREATER_EQUAL "4.2" AND NOT LLDB_EMBED_PYTHON_HOME)
184+
set(default_enable_python_limited_api ON)
185+
else()
186+
set(default_enable_python_limited_api OFF)
187+
endif()
188+
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)"
189+
${default_enable_python_limited_api})
182190
endif()
183191

184192
if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)

llvm/include/llvm/CGData/CodeGenData.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ enum CGDataVersion {
285285
// Version 3 adds the total size of the Names in the stable function map so
286286
// we can skip reading them into the memory for non-assertion builds.
287287
Version3 = 3,
288+
// Version 4 adjusts the structure of stable function merging map for
289+
// efficient lazy loading support.
290+
Version4 = 4,
288291
CurrentVersion = CG_DATA_INDEX_VERSION
289292
};
290293
const uint64_t Version = CGDataVersion::CurrentVersion;

0 commit comments

Comments
 (0)