Skip to content

Commit 17c390f

Browse files
authored
[WPD][LLD] Allow glob matching of --lto-known-safe-vtables (#78505)
Makes it easier to exclude a pattern of safe vtable symbols Testing: ninja check-all
1 parent 47d5967 commit 17c390f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lld/ELF/Driver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,11 @@ static void ltoValidateAllVtablesHaveTypeInfos(opt::InputArgList &args) {
10811081
error("--lto-known-safe-vtables=: expected symbol to start with _ZTV, "
10821082
"but got " +
10831083
knownSafeName);
1084-
vtableSymbolsWithNoRTTI.remove(knownSafeName);
1084+
Expected<GlobPattern> pat = GlobPattern::create(knownSafeName);
1085+
if (!pat)
1086+
error("--lto-known-safe-vtables=: " + toString(pat.takeError()));
1087+
vtableSymbolsWithNoRTTI.remove_if(
1088+
[&](StringRef s) { return pat->match(s); });
10851089
}
10861090

10871091
ctx.ltoAllVtablesHaveTypeInfos = vtableSymbolsWithNoRTTI.empty();

lld/test/ELF/lto/devirt_validate_vtable_typeinfos.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@
125125

126126
;; Index based WPD
127127
; RUN: ld.lld %t1.o %t2_nortti.o -o %t8_index -save-temps --lto-whole-program-visibility --lto-validate-all-vtables-have-type-infos \
128-
; RUN: --lto-known-safe-vtables=_ZTV6Native -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
128+
; RUN: --lto-known-safe-vtables='_ZTV6N*' -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
129129
; RUN: llvm-dis %t1.o.4.opt.bc -o - | FileCheck %s --check-prefixes=CHECK-COMMON-IR-LABEL,CHECK-IR
130130

131131
;; Hybrid WPD
132132
; RUN: ld.lld %t1_hybrid.o %t2_nortti.o -o %t8_hybrid -save-temps --lto-whole-program-visibility --lto-validate-all-vtables-have-type-infos \
133-
; RUN: --lto-known-safe-vtables=_ZTV6Native -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
133+
; RUN: --lto-known-safe-vtables='_ZTV6N*' -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
134134
; RUN: llvm-dis %t1_hybrid.o.4.opt.bc -o - | FileCheck %s --check-prefixes=CHECK-COMMON-IR-LABEL,CHECK-IR
135135

136136
;; Regular LTO WPD
137137
; RUN: ld.lld %t1_regular.o %t2_nortti.o -o %t8_regular -save-temps --lto-whole-program-visibility --lto-validate-all-vtables-have-type-infos \
138-
; RUN: --lto-known-safe-vtables=_ZTV6Native -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
138+
; RUN: --lto-known-safe-vtables='_ZTV6N*' -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
139139
; RUN: llvm-dis %t8_regular.0.4.opt.bc -o - | FileCheck %s --check-prefixes=CHECK-COMMON-IR-LABEL,CHECK-IR
140140

141141
;; Only check for definitions of vtables symbols, just having a reference does not allow a type to

0 commit comments

Comments
 (0)