[lld] r365979 - [COFF] Add null check in case of symbols defined in LTO blobs

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 10:54:49 PDT 2019


Thanks for reverting. I specifically remember standing up from my desk at
5PM on Friday and saying, "it's risky to commit and leave at 5PM on a
Friday, but, I just added a null check, it'll be fine." =P

On Fri, Jul 12, 2019 at 7:19 PM Petr Hosek <phosek at chromium.org> wrote:

> This seems to be failing on our bots with this error:
>
> ******************** TEST 'lld :: COFF/undefined-symbol-lto.test' FAILED
> ********************
> Script:
> --
> : 'RUN: at line 1';   rm -rf
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/tools/lld/test/COFF/Output/undefined-symbol-lto.test.tmp
> && mkdir -p
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/tools/lld/test/COFF/Output/undefined-symbol-lto.test.tmp
> && cd
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/tools/lld/test/COFF/Output/undefined-symbol-lto.test.tmp
> : 'RUN: at line 2';
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/bin/llvm-as
> /b/s/w/ir/k/llvm-project/lld/test/COFF/Inputs/undefined-symbol-lto-a.ll -o
> t.obj
> : 'RUN: at line 3';
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/bin/llvm-as
> /b/s/w/ir/k/llvm-project/lld/test/COFF/Inputs/undefined-symbol-lto-b.ll -o
> b.obj
> : 'RUN: at line 4';   llvm-lib b.obj -out:b.lib
> : 'RUN: at line 5';   not
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/bin/lld-link t.obj
> b.lib -subsystem:console 2>&1 |
> /b/s/w/ir/k/recipe_cleanup/clangHoCU64/llvm_build_dir/bin/FileCheck
> /b/s/w/ir/k/llvm-project/lld/test/COFF/undefined-symbol-lto.test
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /b/s/w/ir/k/llvm-project/lld/test/COFF/undefined-symbol-lto.test:7:8:
> error: CHECK: expected string not found in input
> CHECK: undefined symbol: main
>        ^
> <stdin>:1:1: note: scanning from here
> lld-link: error: could not open 'libcmt.lib': No such file or directory
> ^
>
> On Fri, Jul 12, 2019 at 5:20 PM Reid Kleckner via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: rnk
>> Date: Fri Jul 12 17:20:34 2019
>> New Revision: 365979
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=365979&view=rev
>> Log:
>> [COFF] Add null check in case of symbols defined in LTO blobs
>>
>> The test case could probably be improved further if the failure path was
>> better understood.
>>
>> Fixes PR42536
>>
>> Added:
>>     lld/trunk/test/COFF/Inputs/undefined-symbol-lto-a.ll
>>     lld/trunk/test/COFF/Inputs/undefined-symbol-lto-b.ll
>>     lld/trunk/test/COFF/undefined-symbol-lto.test
>> Modified:
>>     lld/trunk/COFF/SymbolTable.cpp
>>
>> Modified: lld/trunk/COFF/SymbolTable.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=365979&r1=365978&r2=365979&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/COFF/SymbolTable.cpp (original)
>> +++ lld/trunk/COFF/SymbolTable.cpp Fri Jul 12 17:20:34 2019
>> @@ -69,7 +69,7 @@ static Symbol *getSymbol(SectionChunk *s
>>
>>    for (Symbol *s : sc->file->getSymbols()) {
>>      auto *d = dyn_cast_or_null<DefinedRegular>(s);
>> -    if (!d || d->getChunk() != sc || d->getValue() > addr ||
>> +    if (!d || !d->data || d->getChunk() != sc || d->getValue() > addr ||
>>          (candidate && d->getValue() < candidate->getValue()))
>>        continue;
>>
>>
>> Added: lld/trunk/test/COFF/Inputs/undefined-symbol-lto-a.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/undefined-symbol-lto-a.ll?rev=365979&view=auto
>>
>> ==============================================================================
>> --- lld/trunk/test/COFF/Inputs/undefined-symbol-lto-a.ll (added)
>> +++ lld/trunk/test/COFF/Inputs/undefined-symbol-lto-a.ll Fri Jul 12
>> 17:20:34 2019
>> @@ -0,0 +1,82 @@
>> +; ModuleID = 't.obj'
>> +source_filename = "t.cpp"
>> +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
>> +target triple = "x86_64-pc-windows-msvc19.21.27702"
>> +
>> +%struct.Init = type { %struct.S }
>> +%struct.S = type { i32 (...)** }
>> +%rtti.CompleteObjectLocator = type { i32, i32, i32, i32, i32, i32 }
>> +%rtti.TypeDescriptor7 = type { i8**, i8*, [8 x i8] }
>> +%rtti.ClassHierarchyDescriptor = type { i32, i32, i32, i32 }
>> +%rtti.BaseClassDescriptor = type { i32, i32, i32, i32, i32, i32, i32 }
>> +
>> +$"??_SS@@6B@" = comdat largest
>> +
>> +$"??_R4S@@6B@" = comdat any
>> +
>> +$"??_R0?AUS@@@8" = comdat any
>> +
>> +$"??_R3S@@8" = comdat any
>> +
>> +$"??_R2S@@8" = comdat any
>> +
>> +$"??_R1A@?0A at EA@S@@8" = comdat any
>> +
>> +@"?d@@3UInit@@A" = dso_local local_unnamed_addr global %struct.Init
>> zeroinitializer, align 8
>> + at anon.bcb2691509de99310dddb690fcdb4cdc.0 = private unnamed_addr constant
>> { [2 x i8*] } { [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator*
>> @"??_R4S@@6B@" to i8*), i8* bitcast (void (%struct.S*)* @"?foo at S@@UEAAXXZ"
>> to i8*)] }, comdat($"??_SS@@6B@"), !type !0
>> +@"??_R4S@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator {
>> i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint
>> (%rtti.TypeDescriptor7* @"??_R0?AUS@@@8" to i64), i64 ptrtoint (i8*
>> @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint
>> (%rtti.ClassHierarchyDescriptor* @"??_R3S@@8" to i64), i64 ptrtoint (i8*
>> @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint
>> (%rtti.CompleteObjectLocator* @"??_R4S@@6B@" to i64), i64 ptrtoint (i8*
>> @__ImageBase to i64)) to i32) }, comdat
>> +@"??_7type_info@@6B@" = external constant i8*
>> +@"??_R0?AUS@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8**
>> @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUS@@\00" }, comdat
>> + at __ImageBase = external dso_local constant i8
>> +@"??_R3S@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor {
>> i32 0, i32 0, i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint ([2 x i32]*
>> @"??_R2S@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) },
>> comdat
>> +@"??_R2S@@8" = linkonce_odr constant [2 x i32] [i32 trunc (i64 sub nuw
>> nsw (i64 ptrtoint (%rtti.BaseClassDescriptor* @"??_R1A@?0A at EA@S@@8" to
>> i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0], comdat
>> +@"??_R1A@?0A at EA@S@@8" = linkonce_odr constant %rtti.BaseClassDescriptor
>> { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor7*
>> @"??_R0?AUS@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to
>> i32), i32 0, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64
>> ptrtoint (%rtti.ClassHierarchyDescriptor* @"??_R3S@@8" to i64), i64
>> ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
>> + at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{
>> i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_t.cpp, i8* null
>> }]
>> +
>> +@"??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ({ [2 x
>> i8*] }, { [2 x i8*] }* @anon.bcb2691509de99310dddb690fcdb4cdc.0, i32 0, i32
>> 0, i32 1)
>> +
>> +declare dso_local void @"?undefined_ref@@YAXXZ"() local_unnamed_addr #0
>> +
>> +declare dllimport void @"?foo at S@@UEAAXXZ"(%struct.S*) unnamed_addr #0
>> +
>> +; Function Attrs: nounwind sspstrong uwtable
>> +define internal void @_GLOBAL__sub_I_t.cpp() #1 {
>> +entry:
>> +  store i32 (...)** bitcast (i8** @"??_SS@@6B@" to i32 (...)**), i32
>> (...)*** getelementptr inbounds (%struct.Init, %struct.Init* @"?d@
>> @3UInit@@A", i64 0, i32 0, i32 0), align 8
>> +  tail call void @"?undefined_ref@@YAXXZ"() #2
>> +  ret void
>> +}
>> +
>> +attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false"
>> "disable-tail-calls"="false" "less-precise-fpmad"="false"
>> "no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
>> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
>> "no-trapping-math"="false" "stack-protector-buffer-size"="8"
>> "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
>> "unsafe-fp-math"="false" "use-soft-float"="false" }
>> +attributes #1 = { nounwind sspstrong uwtable
>> "correctly-rounded-divide-sqrt-fp-math"="false"
>> "disable-tail-calls"="false" "less-precise-fpmad"="false"
>> "min-legal-vector-width"="0" "no-frame-pointer-elim"="false"
>> "no-infs-fp-math"="false" "no-jump-tables"="false"
>> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
>> "no-trapping-math"="false" "stack-protector-buffer-size"="8"
>> "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
>> "unsafe-fp-math"="false" "use-soft-float"="false" }
>> +attributes #2 = { nounwind }
>> +
>> +!llvm.linker.options = !{!1, !2}
>> +!llvm.module.flags = !{!3, !4, !5, !6}
>> +!llvm.ident = !{!7}
>> +
>> +!0 = !{i64 8, !"?AUS@@"}
>> +!1 = !{!"/DEFAULTLIB:libcmt.lib"}
>> +!2 = !{!"/DEFAULTLIB:oldnames.lib"}
>> +!3 = !{i32 1, !"wchar_size", i32 2}
>> +!4 = !{i32 7, !"PIC Level", i32 2}
>> +!5 = !{i32 1, !"ThinLTO", i32 0}
>> +!6 = !{i32 1, !"EnableSplitLTOUnit", i32 0}
>> +!7 = !{!"clang version 9.0.0 (git at github.com:llvm/llvm-project.git
>> 1a285c27fdf6407ceed3398e015d00559f5f533d)"}
>> +
>> +^0 = module: (path: "t.obj", hash: (0, 0, 0, 0, 0))
>> +^1 = gv: (name: "__ImageBase") ; guid = 434928772013489304
>> +^2 = gv: (name: "??_R2S@@8", summaries: (variable: (module: ^0, flags:
>> (linkage: linkonce_odr, notEligibleToImport: 1, live: 0, dsoLocal: 0,
>> canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^1, ^6)))) ;
>> guid = 2160898732728284029
>> +^3 = gv: (name: "llvm.global_ctors", summaries: (variable: (module: ^0,
>> flags: (linkage: appending, notEligibleToImport: 1, live: 1, dsoLocal: 0,
>> canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^14)))) ;
>> guid = 2412314959268824392
>> +^4 = gv: (name: "?foo at S@@UEAAXXZ") ; guid = 6578172636330484861
>> +^5 = gv: (name: "??_SS@@6B@", summaries: (alias: (module: ^0, flags:
>> (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 0,
>> canAutoHide: 0), aliasee: ^10))) ; guid = 8774897714842691026
>> +^6 = gv: (name: "??_R1A@?0A at EA@S@@8", summaries: (variable: (module:
>> ^0, flags: (linkage: linkonce_odr, notEligibleToImport: 1, live: 0,
>> dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs:
>> (^11, ^1, ^8)))) ; guid = 9397802696236423453
>> +^7 = gv: (name: "?undefined_ref@@YAXXZ") ; guid = 9774674600202276560
>> +^8 = gv: (name: "??_R3S@@8", summaries: (variable: (module: ^0, flags:
>> (linkage: linkonce_odr, notEligibleToImport: 1, live: 0, dsoLocal: 0,
>> canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^1, ^2)))) ;
>> guid = 10685958509605791599
>> +^9 = gv: (name: "??_7type_info@@6B@") ; guid = 10826752452437539368
>> +^10 = gv: (name: "anon.bcb2691509de99310dddb690fcdb4cdc.0", summaries:
>> (variable: (module: ^0, flags: (linkage: private, notEligibleToImport: 1,
>> live: 0, dsoLocal: 1, canAutoHide: 0), varFlags: (readonly: 0, writeonly:
>> 0), vTableFuncs: ((virtFunc: ^4, offset: 8)), refs: (^13, ^4)))) ; guid =
>> 11510395461204283992
>> +^11 = gv: (name: "??_R0?AUS@@@8", summaries: (variable: (module: ^0,
>> flags: (linkage: linkonce_odr, notEligibleToImport: 1, live: 0, dsoLocal:
>> 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^9)))) ;
>> guid = 12346607659584231960
>> +^12 = gv: (name: "?d@@3UInit@@A", summaries: (variable: (module: ^0,
>> flags: (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 1,
>> canAutoHide: 0), varFlags: (readonly: 1, writeonly: 1)))) ; guid =
>> 14563354643524156382
>> +^13 = gv: (name: "??_R4S@@6B@", summaries: (variable: (module: ^0,
>> flags: (linkage: linkonce_odr, notEligibleToImport: 1, live: 0, dsoLocal:
>> 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^13, ^11,
>> ^1, ^8)))) ; guid = 14703528065171087394
>> +^14 = gv: (name: "_GLOBAL__sub_I_t.cpp", summaries: (function: (module:
>> ^0, flags: (linkage: internal, notEligibleToImport: 1, live: 0, dsoLocal:
>> 1, canAutoHide: 0), insts: 3, calls: ((callee: ^7)), refs: (^12, ^5)))) ;
>> guid = 15085897428757412588
>> +^15 = typeidCompatibleVTable: (name: "?AUS@@", summary: ((offset: 8,
>> ^10))) ; guid = 13986515119763165370
>>
>> Added: lld/trunk/test/COFF/Inputs/undefined-symbol-lto-b.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/undefined-symbol-lto-b.ll?rev=365979&view=auto
>>
>> ==============================================================================
>> --- lld/trunk/test/COFF/Inputs/undefined-symbol-lto-b.ll (added)
>> +++ lld/trunk/test/COFF/Inputs/undefined-symbol-lto-b.ll Fri Jul 12
>> 17:20:34 2019
>> @@ -0,0 +1,29 @@
>> +; ModuleID = 'b.obj'
>> +source_filename = "b.cpp"
>> +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
>> +target triple = "x86_64-pc-windows-msvc19.21.27702"
>> +
>> +%struct.S = type { i32 (...)** }
>> +
>> +; Function Attrs: norecurse nounwind readnone sspstrong uwtable
>> +define dso_local void @"?foo at S@@UEAAXXZ"(%struct.S* nocapture %this)
>> unnamed_addr #0 align 2 {
>> +entry:
>> +  ret void
>> +}
>> +
>> +attributes #0 = { norecurse nounwind readnone sspstrong uwtable
>> "correctly-rounded-divide-sqrt-fp-math"="false"
>> "disable-tail-calls"="false" "less-precise-fpmad"="false"
>> "min-legal-vector-width"="0" "no-frame-pointer-elim"="false"
>> "no-infs-fp-math"="false" "no-jump-tables"="false"
>> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
>> "no-trapping-math"="false" "stack-protector-buffer-size"="8"
>> "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
>> "unsafe-fp-math"="false" "use-soft-float"="false" }
>> +
>> +!llvm.linker.options = !{!0, !1}
>> +!llvm.module.flags = !{!2, !3, !4, !5}
>> +!llvm.ident = !{!6}
>> +
>> +!0 = !{!"/DEFAULTLIB:libcmt.lib"}
>> +!1 = !{!"/DEFAULTLIB:oldnames.lib"}
>> +!2 = !{i32 1, !"wchar_size", i32 2}
>> +!3 = !{i32 7, !"PIC Level", i32 2}
>> +!4 = !{i32 1, !"ThinLTO", i32 0}
>> +!5 = !{i32 1, !"EnableSplitLTOUnit", i32 0}
>> +!6 = !{!"clang version 9.0.0 (git at github.com:llvm/llvm-project.git
>> 1a285c27fdf6407ceed3398e015d00559f5f533d)"}
>> +
>> +^0 = module: (path: "b.obj", hash: (0, 0, 0, 0, 0))
>> +^1 = gv: (name: "?foo at S@@UEAAXXZ", summaries: (function: (module: ^0,
>> flags: (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 1,
>> canAutoHide: 0), insts: 1, funcFlags: (readNone: 1, readOnly: 0, noRecurse:
>> 1, returnDoesNotAlias: 0, noInline: 0)))) ; guid = 6578172636330484861
>>
>> Added: lld/trunk/test/COFF/undefined-symbol-lto.test
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/undefined-symbol-lto.test?rev=365979&view=auto
>>
>> ==============================================================================
>> --- lld/trunk/test/COFF/undefined-symbol-lto.test (added)
>> +++ lld/trunk/test/COFF/undefined-symbol-lto.test Fri Jul 12 17:20:34 2019
>> @@ -0,0 +1,30 @@
>> +RUN: rm -rf %t && mkdir -p %t && cd %t
>> +RUN: llvm-as %S/Inputs/undefined-symbol-lto-a.ll -o t.obj
>> +RUN: llvm-as %S/Inputs/undefined-symbol-lto-b.ll -o b.obj
>> +RUN: llvm-lib b.obj -out:b.lib
>> +RUN: not lld-link t.obj b.lib -subsystem:console 2>&1 | FileCheck %s
>> +
>> +CHECK: undefined symbol: main
>> +CHECK: referenced by
>> +CHECK: undefined symbol: void __cdecl undefined_ref(void)
>> +CHECK: referenced by
>> +
>> +Originally reported as PR42536.
>> +
>> +a.ll corresponds to this C++:
>> +
>> +struct __declspec(dllimport) S {
>> +  virtual void foo();
>> +};
>> +void undefined_ref();
>> +struct Init {
>> +  Init() { undefined_ref(); }
>> +  S c;
>> +} d;
>> +
>> +b.ll is from this C++:
>> +
>> +struct S {
>> +  virtual void foo();
>> +};
>> +void S::foo() {}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190715/8f388a76/attachment.html>


More information about the llvm-commits mailing list