Index: docs/LinkTimeOptimization.rst =================================================================== --- docs/LinkTimeOptimization.rst +++ docs/LinkTimeOptimization.rst @@ -87,9 +87,9 @@ .. code-block:: console - % clang -emit-llvm -c a.c -o a.o # <-- a.o is LLVM bitcode file + % clang -flto -c a.c -o a.o # <-- a.o is LLVM bitcode file % clang -c main.c -o main.o # <-- main.o is native object file - % clang a.o main.o -o main # <-- standard link command without modifications + % clang -flto a.o main.o -o main # <-- standard link command without modifications * In this example, the linker recognizes that ``foo2()`` is an externally visible symbol defined in LLVM bitcode file. The linker completes its usual Index: lib/Transforms/IPO/FunctionImport.cpp =================================================================== --- lib/Transforms/IPO/FunctionImport.cpp +++ lib/Transforms/IPO/FunctionImport.cpp @@ -591,12 +591,14 @@ << SrcModule->getSourceFileName() << "\n"); if (Import) { F.materialize(); +#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS) // Add 'thinlto_src_module' metadata for statistics and debugging. F.setMetadata("thinlto_src_module", llvm::MDNode::get(DestModule.getContext(), {llvm::MDString::get( DestModule.getContext(), SrcModule->getSourceFileName())})); +#endif // !defined(NDEBUG) || defined(LLVM_ENABLE_STATS) GlobalsToImport.insert(&F); } }