Skip to content

Commit 037c284

Browse files
author
apple-llvm-mt
committed
Merge root: Add github lockdown app to auto-close pull requests.
apple-llvm-split-dir: -
2 parents cc411a7 + b37f2f3 commit 037c284

File tree

222 files changed

+4421
-1770
lines changed

Some content is hidden

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

222 files changed

+4421
-1770
lines changed

.github/lockdown.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Configuration for Repo Lockdown - https://github.com/dessant/repo-lockdown
2+
3+
# Skip issues and pull requests created before a given timestamp. Timestamp must
4+
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
5+
skipCreatedBefore: false
6+
7+
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
8+
exemptLabels: []
9+
10+
# Comment to post before closing or locking. Set to `false` to disable
11+
comment: true
12+
13+
# Label to add before closing or locking. Set to `false` to disable
14+
label: false
15+
16+
# Close issues and pull requests
17+
close: true
18+
19+
# Lock issues and pull requests
20+
lock: true
21+
22+
# Limit to only `issues` or `pulls`
23+
# only: issues
24+
25+
# Optionally, specify configuration settings just for `issues` or `pulls`
26+
# issues:
27+
# label: wontfix
28+
29+
pulls:
30+
comment: >
31+
This repository does not accept pull requests.
32+
Please follow http://llvm.org/docs/Contributing.html#how-to-submit-a-patch for contribution to LLVM.
33+

debuginfo-tests/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_required_attr(config, attr_name):
8989

9090
if platform.system() == 'Darwin':
9191
import subprocess
92-
xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version'])
92+
xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version']).decode("utf-8")
9393
match = re.search('lldb-(\d+)', xcode_lldb_vers)
9494
if match:
9595
apple_lldb_vers = int(match.group(1))

debuginfo-tests/nrvo-string.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,32 @@ struct string {
1717
string get_string() {
1818
string unused;
1919
string result = 3;
20-
// DEBUGGER: break 21
20+
// DEBUGGER: break 21
2121
return result;
2222
}
23-
int main() { get_string(); }
23+
void some_function(int) {}
24+
struct string2 {
25+
string2() = default;
26+
string2(string2 &&other) { i = other.i; }
27+
int i;
28+
};
29+
string2 get_string2() {
30+
string2 result;
31+
result.i = 5;
32+
some_function(result.i);
33+
// Test that the debugger can get the value of result after another
34+
// function is called.
35+
// DEBUGGER: break 35
36+
return result;
37+
}
38+
int main() {
39+
get_string();
40+
get_string2();
41+
}
2442

2543
// DEBUGGER: r
2644
// DEBUGGER: print result.i
2745
// CHECK: = 3
46+
// DEBUGGER: c
47+
// DEBUGGER: print result.i
48+
// CHECK: = 5

debuginfo-tests/win_cdb/nrvo.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
2+
// of a string object occurs in C++.
3+
//
4+
// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
5+
// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
6+
// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
7+
//
8+
9+
struct string {
10+
string() {}
11+
string(int i) : i(i) {}
12+
~string() {}
13+
int i = 0;
14+
};
15+
string get_string() {
16+
string unused;
17+
string result = 3;
18+
__debugbreak();
19+
return result;
20+
}
21+
void some_function(int) {}
22+
struct string2 {
23+
string2() = default;
24+
string2(string2 &&other) { i = other.i; }
25+
int i;
26+
};
27+
string2 get_string2() {
28+
string2 result;
29+
result.i = 5;
30+
some_function(result.i);
31+
// Test that the debugger can get the value of result after another
32+
// function is called.
33+
__debugbreak();
34+
return result;
35+
}
36+
int main() {
37+
get_string();
38+
get_string2();
39+
}
40+
41+
// DEBUGGER: g
42+
// DEBUGGER: ?? result
43+
// CHECK: struct string *
44+
// CHECK: +0x000 i : 0n3
45+
// DEBUGGER: g
46+
// DEBUGGER: ?? result
47+
// CHECK: struct string2 *
48+
// CHECK: +0x000 i : 0n5
49+
// DEBUGGER: q

lld/COFF/Chunks.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,15 @@ static void maybeReportRelocationToDiscarded(const SectionChunk *FromChunk,
336336
File->getCOFFObj()->getSymbolName(COFFSym, Name);
337337
}
338338

339-
error("relocation against symbol in discarded section: " + Name +
340-
getSymbolLocations(File, Rel.SymbolTableIndex));
339+
std::vector<std::string> SymbolLocations =
340+
getSymbolLocations(File, Rel.SymbolTableIndex);
341+
342+
std::string Out;
343+
llvm::raw_string_ostream OS(Out);
344+
OS << "relocation against symbol in discarded section: " + Name;
345+
for (const std::string &S : SymbolLocations)
346+
OS << S;
347+
error(OS.str());
341348
}
342349

343350
void SectionChunk::writeTo(uint8_t *Buf) const {

lld/COFF/SymbolTable.cpp

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ static Symbol *getSymbol(SectionChunk *SC, uint32_t Addr) {
7979
return Candidate;
8080
}
8181

82-
std::string getSymbolLocations(ObjFile *File, uint32_t SymIndex) {
82+
// Given a file and the index of a symbol in that file, returns a description
83+
// of all references to that symbol from that file. If no debug information is
84+
// available, returns just the name of the file, else one string per actual
85+
// reference as described in the debug info.
86+
std::vector<std::string> getSymbolLocations(ObjFile *File, uint32_t SymIndex) {
8387
struct Location {
8488
Symbol *Sym;
8589
std::pair<StringRef, uint32_t> FileLine;
@@ -102,11 +106,12 @@ std::string getSymbolLocations(ObjFile *File, uint32_t SymIndex) {
102106
}
103107

104108
if (Locations.empty())
105-
return "\n>>> referenced by " + toString(File);
109+
return std::vector<std::string>({"\n>>> referenced by " + toString(File)});
106110

107-
std::string Out;
108-
llvm::raw_string_ostream OS(Out);
111+
std::vector<std::string> SymbolLocations(Locations.size());
112+
size_t I = 0;
109113
for (Location Loc : Locations) {
114+
llvm::raw_string_ostream OS(SymbolLocations[I++]);
110115
OS << "\n>>> referenced by ";
111116
if (!Loc.FileLine.first.empty())
112117
OS << Loc.FileLine.first << ":" << Loc.FileLine.second
@@ -115,7 +120,41 @@ std::string getSymbolLocations(ObjFile *File, uint32_t SymIndex) {
115120
if (Loc.Sym)
116121
OS << ":(" << toString(*Loc.Sym) << ')';
117122
}
118-
return OS.str();
123+
return SymbolLocations;
124+
}
125+
126+
// For an undefined symbol, stores all files referencing it and the index of
127+
// the undefined symbol in each file.
128+
struct UndefinedDiag {
129+
Symbol *Sym;
130+
struct File {
131+
ObjFile *File;
132+
uint64_t SymIndex;
133+
};
134+
std::vector<File> Files;
135+
};
136+
137+
static void reportUndefinedSymbol(const UndefinedDiag &UndefDiag) {
138+
std::string Out;
139+
llvm::raw_string_ostream OS(Out);
140+
OS << "undefined symbol: " << toString(*UndefDiag.Sym);
141+
142+
const size_t MaxUndefReferences = 10;
143+
size_t I = 0, NumRefs = 0;
144+
for (const UndefinedDiag::File &Ref : UndefDiag.Files) {
145+
std::vector<std::string> SymbolLocations =
146+
getSymbolLocations(Ref.File, Ref.SymIndex);
147+
NumRefs += SymbolLocations.size();
148+
for (const std::string &S : SymbolLocations) {
149+
if (I >= MaxUndefReferences)
150+
break;
151+
OS << S;
152+
I++;
153+
}
154+
}
155+
if (I < NumRefs)
156+
OS << "\n>>> referenced " << NumRefs - I << " more times";
157+
errorOrWarn(OS.str());
119158
}
120159

121160
void SymbolTable::loadMinGWAutomaticImports() {
@@ -263,22 +302,34 @@ void SymbolTable::reportRemainingUndefines() {
263302
" (defined in " + toString(Imp->getFile()) + ") [LNK4217]");
264303
}
265304

305+
std::vector<UndefinedDiag> UndefDiags;
306+
DenseMap<Symbol *, int> FirstDiag;
307+
266308
for (ObjFile *File : ObjFile::Instances) {
267309
size_t SymIndex = (size_t)-1;
268310
for (Symbol *Sym : File->getSymbols()) {
269311
++SymIndex;
270312
if (!Sym)
271313
continue;
272-
if (Undefs.count(Sym))
273-
errorOrWarn("undefined symbol: " + toString(*Sym) +
274-
getSymbolLocations(File, SymIndex));
314+
if (Undefs.count(Sym)) {
315+
auto it = FirstDiag.find(Sym);
316+
if (it == FirstDiag.end()) {
317+
FirstDiag[Sym] = UndefDiags.size();
318+
UndefDiags.push_back({Sym, {{File, SymIndex}}});
319+
} else {
320+
UndefDiags[it->second].Files.push_back({File, SymIndex});
321+
}
322+
}
275323
if (Config->WarnLocallyDefinedImported)
276324
if (Symbol *Imp = LocalImports.lookup(Sym))
277325
warn(toString(File) +
278326
": locally defined symbol imported: " + toString(*Imp) +
279327
" (defined in " + toString(Imp->getFile()) + ") [LNK4217]");
280328
}
281329
}
330+
331+
for (const UndefinedDiag& UndefDiag : UndefDiags)
332+
reportUndefinedSymbol(UndefDiag);
282333
}
283334

284335
std::pair<Symbol *, bool> SymbolTable::insert(StringRef Name) {

lld/COFF/SymbolTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class SymbolTable {
123123

124124
extern SymbolTable *Symtab;
125125

126-
std::string getSymbolLocations(ObjFile *File, uint32_t SymIndex);
126+
std::vector<std::string> getSymbolLocations(ObjFile *File, uint32_t SymIndex);
127127

128128
} // namespace coff
129129
} // namespace lld

lld/ELF/Arch/AArch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ bool AArch64::usesOnlyLowPageBits(RelType Type) const {
146146
}
147147

148148
RelType AArch64::getDynRel(RelType Type) const {
149-
if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
149+
if (Type == R_AARCH64_ABS64)
150150
return Type;
151151
return R_AARCH64_NONE;
152152
}

lld/ELF/Arch/AMDGPU.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class AMDGPU final : public TargetInfo {
2828
void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
2929
RelExpr getRelExpr(RelType Type, const Symbol &S,
3030
const uint8_t *Loc) const override;
31+
RelType getDynRel(RelType Type) const override;
3132
};
3233
} // namespace
3334

@@ -100,6 +101,12 @@ RelExpr AMDGPU::getRelExpr(RelType Type, const Symbol &S,
100101
}
101102
}
102103

104+
RelType AMDGPU::getDynRel(RelType Type) const {
105+
if (Type == R_AMDGPU_ABS64)
106+
return Type;
107+
return R_AMDGPU_NONE;
108+
}
109+
103110
TargetInfo *elf::getAMDGPUTargetInfo() {
104111
static AMDGPU Target;
105112
return &Target;

lld/ELF/Arch/ARM.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,6 @@ void ARM::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
395395
case R_ARM_TLS_DTPOFF32:
396396
write32le(Loc, Val);
397397
break;
398-
case R_ARM_TLS_DTPMOD32:
399-
write32le(Loc, 1);
400-
break;
401398
case R_ARM_PREL31:
402399
checkInt(Loc, Val, 31, Type);
403400
write32le(Loc, (read32le(Loc) & 0x80000000) | (Val & ~0x80000000));

lld/ELF/Arch/Mips.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType Type, const Symbol &S,
182182
}
183183

184184
template <class ELFT> RelType MIPS<ELFT>::getDynRel(RelType Type) const {
185-
if (Type == R_MIPS_32 || Type == R_MIPS_64)
186-
return RelativeRel;
185+
if (Type == SymbolicRel)
186+
return Type;
187187
return R_MIPS_NONE;
188188
}
189189

lld/ELF/Arch/PPC.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ namespace {
2323
class PPC final : public TargetInfo {
2424
public:
2525
PPC();
26+
RelExpr getRelExpr(RelType Type, const Symbol &S,
27+
const uint8_t *Loc) const override;
28+
RelType getDynRel(RelType Type) const override;
2629
void writeGotHeader(uint8_t *Buf) const override;
2730
void writePltHeader(uint8_t *Buf) const override {
2831
llvm_unreachable("should call writePPC32GlinkSection() instead");
@@ -36,8 +39,6 @@ class PPC final : public TargetInfo {
3639
uint64_t BranchAddr, const Symbol &S) const override;
3740
uint32_t getThunkSectionSpacing() const override;
3841
bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const override;
39-
RelExpr getRelExpr(RelType Type, const Symbol &S,
40-
const uint8_t *Loc) const override;
4142
void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
4243
RelExpr adjustRelaxExpr(RelType Type, const uint8_t *Data,
4344
RelExpr Expr) const override;
@@ -230,6 +231,12 @@ RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
230231
}
231232
}
232233

234+
RelType PPC::getDynRel(RelType Type) const {
235+
if (Type == R_PPC_ADDR32)
236+
return Type;
237+
return R_PPC_NONE;
238+
}
239+
233240
static std::pair<RelType, uint64_t> fromDTPREL(RelType Type, uint64_t Val) {
234241
uint64_t DTPBiasedVal = Val - 0x8000;
235242
switch (Type) {
@@ -253,6 +260,9 @@ void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
253260
std::tie(NewType, Val) = fromDTPREL(Type, Val);
254261
switch (NewType) {
255262
case R_PPC_ADDR16:
263+
checkIntUInt(Loc, Val, 16, Type);
264+
write16(Loc, Val);
265+
break;
256266
case R_PPC_GOT16:
257267
case R_PPC_GOT_TLSGD16:
258268
case R_PPC_GOT_TLSLD16:

0 commit comments

Comments
 (0)