Skip to content

Commit 259556a

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:7ac532efc8ae into amd-gfx:d8f80774ebd7
Local branch amd-gfx d8f8077 Merged main:ab472cd4ea12 into amd-gfx:881edfeace15 Remote branch main 7ac532e [AMDGPU] Introduce AMDGPU::SGPR_SPILL asm comment flag (llvm#67091)
2 parents d8f8077 + 7ac532e commit 259556a

39 files changed

+188
-67
lines changed

clang/lib/Interpreter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
44
MC
55
Option
66
OrcJit
7+
OrcDebugging
78
OrcShared
89
OrcTargetProcess
910
Support

clang/lib/Interpreter/IncrementalExecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "clang/Interpreter/PartialTranslationUnit.h"
1818
#include "llvm/ExecutionEngine/ExecutionEngine.h"
1919
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
20-
#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
20+
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
2121
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
2222
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2323
#include "llvm/ExecutionEngine/Orc/LLJIT.h"

clang/test/AST/Interp/arrays.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2-
// RUN: %clang_cc1 -verify=ref %s
2+
// RUN: %clang_cc1 -verify=ref -DCUR_INTERP %s
33

44
constexpr int m = 3;
55
constexpr const int *foo[][5] = {
@@ -350,3 +350,24 @@ namespace ZeroInit {
350350
static_assert(b.f[0] == 0.0, "");
351351
static_assert(b.f[1] == 0.0, "");
352352
}
353+
354+
namespace ArrayInitLoop {
355+
/// FIXME: The ArrayInitLoop for the decomposition initializer in g() has
356+
/// f(n) as its CommonExpr. We need to evaluate that exactly once and not
357+
/// N times as we do right now.
358+
#ifndef CUR_INTERP
359+
struct X {
360+
int arr[3];
361+
};
362+
constexpr X f(int &r) {
363+
return {++r, ++r, ++r};
364+
}
365+
constexpr int g() {
366+
int n = 0;
367+
auto [a, b, c] = f(n).arr;
368+
return a + b + c;
369+
}
370+
static_assert(g() == 6); // expected-error {{failed}} \
371+
// expected-note {{15 == 6}}
372+
#endif
373+
}

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476309
19+
#define LLVM_MAIN_REVISION 476314
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/ExecutionEngine/Orc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ add_llvm_component_library(LLVMOrcJIT
1313
CompileUtils.cpp
1414
Core.cpp
1515
DebugObjectManagerPlugin.cpp
16-
DebuggerSupport.cpp
17-
DebuggerSupportPlugin.cpp
1816
DebugUtils.cpp
1917
EPCDynamicLibrarySearchGenerator.cpp
2018
EPCDebugObjectRegistrar.cpp

llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ endif()
44

55
add_llvm_component_library(LLVMOrcDebugging
66
DebugInfoSupport.cpp
7+
DebuggerSupport.cpp
8+
DebuggerSupportPlugin.cpp
79
PerfSupportPlugin.cpp
810

911
ADDITIONAL_HEADER_DIRS
@@ -15,6 +17,7 @@ add_llvm_component_library(LLVMOrcDebugging
1517

1618
LINK_COMPONENTS
1719
DebugInfoDWARF
20+
JITLink
1821
OrcJIT
1922
OrcShared
2023
Support

llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp renamed to llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
9+
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
1010
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
11-
#include "llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h"
11+
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"
1212
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
1313

1414
#define DEBUG_TYPE "orc"

llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp renamed to llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#include "llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h"
12+
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"
1313
#include "llvm/ExecutionEngine/Orc/MachOBuilder.h"
1414

1515
#include "llvm/ADT/SmallSet.h"
1616
#include "llvm/ADT/SmallVector.h"
1717
#include "llvm/ADT/StringSet.h"
1818
#include "llvm/BinaryFormat/MachO.h"
19+
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
20+
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
21+
22+
#include <chrono>
1923

2024
#define DEBUG_TYPE "orc"
2125

@@ -97,8 +101,6 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
97101
<< "\n";
98102
});
99103

100-
auto &SDOSec = G.createSection(SynthDebugSectionName, MemProt::Read);
101-
102104
for (auto &Sec : G.sections()) {
103105
if (Sec.blocks().empty())
104106
continue;
@@ -114,6 +116,10 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
114116
NonDebugSections.push_back({&Sec, nullptr});
115117
}
116118

119+
// Bail out early if no debug sections.
120+
if (DebugSections.empty())
121+
return Error::success();
122+
117123
// Write MachO header and debug section load commands.
118124
Builder.Header.filetype = MachO::MH_OBJECT;
119125
switch (G.getTargetTriple().getArch()) {
@@ -131,16 +137,65 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
131137

132138
Seg = &Builder.addSegment("");
133139

140+
StringMap<std::unique_ptr<MemoryBuffer>> DebugSectionMap;
141+
StringRef DebugLineSectionData;
134142
for (auto &DSec : DebugSections) {
135143
auto [SegName, SecName] = DSec.GraphSec->getName().split(',');
136144
DSec.BuilderSec = &Seg->addSection(SecName, SegName);
137145

138146
SectionRange SR(*DSec.GraphSec);
139147
DSec.BuilderSec->Content.Size = SR.getSize();
140-
if (!SR.empty())
148+
if (!SR.empty()) {
141149
DSec.BuilderSec->align = Log2_64(SR.getFirstBlock()->getAlignment());
150+
StringRef SectionData(SR.getFirstBlock()->getContent().data(),
151+
SR.getFirstBlock()->getSize());
152+
DebugSectionMap[SecName] =
153+
MemoryBuffer::getMemBuffer(SectionData, G.getName(), false);
154+
if (SecName == "__debug_line")
155+
DebugLineSectionData = SectionData;
156+
}
142157
}
143158

159+
std::optional<std::string> FileName;
160+
if (!DebugLineSectionData.empty()) {
161+
auto DWARFCtx = DWARFContext::create(DebugSectionMap, G.getPointerSize(),
162+
G.getEndianness());
163+
DWARFDataExtractor DebugLineData(
164+
DebugLineSectionData,
165+
G.getEndianness() == support::endianness::little, G.getPointerSize());
166+
uint64_t Offset = 0;
167+
DWARFDebugLine::LineTable LineTable;
168+
169+
// Try to parse line data. Consume error on failure.
170+
if (auto Err = LineTable.parse(DebugLineData, &Offset, *DWARFCtx, nullptr,
171+
consumeError)) {
172+
handleAllErrors(
173+
std::move(Err),
174+
[&](ErrorInfoBase &EIB) {
175+
LLVM_DEBUG({
176+
dbgs() << "Cannot parse line table for \"" << G.getName() << "\": ";
177+
EIB.log(dbgs());
178+
dbgs() << "\n";
179+
});
180+
});
181+
} else {
182+
if (!LineTable.Prologue.FileNames.empty())
183+
FileName = *dwarf::toString(LineTable.Prologue.FileNames[0].Name);
184+
}
185+
}
186+
187+
// If no line table (or unable to use) then use graph name.
188+
// FIXME: There are probably other debug sections we should look in first.
189+
if (!FileName)
190+
FileName = G.getName();
191+
192+
Builder.addSymbol("", MachO::N_SO, 0, 0, 0);
193+
Builder.addSymbol(*FileName, MachO::N_SO, 0, 0, 0);
194+
auto TimeStamp = std::chrono::duration_cast<std::chrono::seconds>(
195+
std::chrono::system_clock::now().time_since_epoch())
196+
.count();
197+
Builder.addSymbol("", MachO::N_OSO, 3, 1, TimeStamp);
198+
144199
for (auto &NDSP : NonDebugSections) {
145200
auto [SegName, SecName] = NDSP.GraphSec->getName().split(',');
146201
NDSP.BuilderSec = &Seg->addSection(SecName, SegName);
@@ -164,8 +219,12 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
164219
}
165220
}
166221

222+
Builder.addSymbol("", MachO::N_SO, 1, 0, 0);
223+
224+
// Lay out the debug object, create a section and block for it.
167225
size_t DebugObjectSize = Builder.layout();
168226

227+
auto &SDOSec = G.createSection(SynthDebugSectionName, MemProt::Read);
169228
MachOContainerBlock = &G.createMutableContentBlock(
170229
SDOSec, G.allocateBuffer(DebugObjectSize), orc::ExecutorAddr(), 8, 0);
171230

0 commit comments

Comments
 (0)