https://llvm.org/bugs/show_bug.cgi?id=28554
Bug ID: 28554 Summary: LLD fails to devirtualize the code that Gold plugin does Product: lld Version: unspecified Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: ELF Assignee: unassignedb...@nondot.org Reporter: kra...@google.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16742 --> https://llvm.org/bugs/attachment.cgi?id=16742&action=edit devirt.cc Consider the attached program, devirt.cc. With Gold and LLVM Gold plugin we get: $ clang++ -O2 -fuse-ld=gold -o lala -fvisibility=hidden devirt.cc -std=c++11 -flto -fwhole-program-vtables -Wl,-plugin-opt,-pass-remarks=wholeprogramdevirt -Wl,-plugin-opt,O1 -Wl,-plugin-opt,-function-sections -Wl,-plugin-opt,save-temps LLVM gold plugin: <unknown>:0:0: devirtualized call LLVM gold plugin: <unknown>:0:0: devirtualized call LLVM gold plugin: <unknown>:0:0: devirtualized call $ In the bitcode (lala.opt.bc) we see the call was devirtualized: %vfn = getelementptr inbounds i1 (%class.Base*, i32)*, i1 (%class.Base*, i32)** %vtable, i64 2 %10 = load i1 (%class.Base*, i32)*, i1 (%class.Base*, i32)** %vfn, align 8 %11 = icmp ne i8* %9, getelementptr (i8, i8* bitcast ([6 x i8*]* @_ZTV1A to i8*), i64 16) %conv = zext i1 %11 to i32 %call19 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %conv) If we link with lld, nothing happens: $ clang++ -fuse-ld=lld -o lala devirt.cc -std=c++11 -flto -fvisibility=hidden -fwhole-program-vtables -Wl,-mllvm,-pass-remarks=wholeprogramdevirt -Wl,--lto-O1 -Wl,-save-temps $ And the bitcode shows that we still have a virtual call: %vfn = getelementptr inbounds i1 (%class.Base*, i32)*, i1 (%class.Base*, i32)** %vtable, i64 2 %19 = load i1 (%class.Base*, i32)*, i1 (%class.Base*, i32)** %vfn, align 8 %call17 = invoke zeroext i1 %19(%class.Base* %call15, i32 1) to label %invoke.cont16 unwind label %lpad invoke.cont16: ; preds = %sw.epilog %conv = zext i1 %call17 to i32 %call19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %conv) This prevents lld from being deployed in Chromium as the default linker on Linux. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs