<div dir="ltr">FYI, while I try to resolve bitcode dependence issue (D26502), I have resubmitted the half of this patch that didn't require the new dependence (the part that deals with uses in module level asm) in r286475. The def handling will have to wait.<div><br></div><div>Teresa</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 9, 2016 at 6:29 AM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Nov 8, 2016 at 5:46 PM, David Jones <span dir="ltr"><<a href="mailto:dlj@google.com" target="_blank">dlj@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It looks like this adds a new layering violation:<div><br></div><div>Analysis/ModuleSummaryAnalysis<wbr>.cpp -></div><div>Object/IRObjectFile -></div><div>Bitcode -></div><div>Analysis</div></div></blockquote><div><br></div></span><div>I'm confused about the issue. The dependences I see with this change are:</div><div><br></div><div>Analysis -> Object -> BitReader</div><div>and</div><div>BitWriter -> Analysis</div><div><br></div><div>There isn't a single Bitcode library, and so there is no cycle (upstream).</div><div><br></div><div>Looking at the way we treat the Bitcode subdirectory internally looks like it might be causing the issue, which was detected internally. We are representing as a single Bitcode library. That should be fixed to mirror the way the libraries are built upstream. David, let me see if I can fix our internal structure so that this can be resubmitted.</div><div><br></div><div>Or am I missing something?</div><div><br></div><div>Thanks,</div><div>Teresa</div><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>In particular, the long pole appears to be IRObjectFile::CollectAsmUndefi<wbr>nedRefs. It is almost independent of Object, except for BasicSymbolRef::Flags.</div><div><br></div><div>Ben and I looked at it for a bit but didn't see any obvious moves. Teresa, Mehdi, any ideas?</div></div><div class="m_-7316144437542370060HOEnZb"><div class="m_-7316144437542370060h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 8, 2016 at 1:53 PM, Teresa Johnson via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tejohnson<br>
Date: Tue Nov 8 15:53:35 2016<br>
New Revision: 286297<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=286297&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=286297&view=rev</a><br>
Log:<br>
[ThinLTO] Prevent exporting of locals used/defined in module level asm<br>
<br>
Summary:<br>
This patch uses the same approach added for inline asm in r285513 to<br>
similarly prevent promotion/renaming of locals used or defined in module<br>
level asm.<br>
<br>
All static global values defined in normal IR and used in module level asm<br>
should be included on either the llvm.used or llvm.compiler.used global.<br>
The former were already being flagged as NoRename in the summary, and<br>
I've simply added llvm.compiler.used values to this handling.<br>
<br>
Module level asm may also contain defs of values. We need to prevent<br>
export of any refs to local values defined in module level asm (e.g. a<br>
ref in normal IR), since that also requires renaming/promotion of the<br>
local. To do that, the summary index builder looks at all values in the<br>
module level asm string that are not marked Weak or Global, which is<br>
exactly the set of locals that are defined. A summary is created for<br>
each of these local defs and flagged as NoRename.<br>
<br>
This required adding handling to the BitcodeWriter to look at GV<br>
declarations to see if they have a summary (rather than skipping them<br>
all).<br>
<br>
Finally, added an assert to IRObjectFile::CollectAsmUndefi<wbr>nedRefs to<br>
ensure that an MCAsmParser is available, otherwise the module asm parse<br>
would silently fail. Initialized the asm parser in the opt tool for use<br>
in testing this fix.<br>
<br>
Fixes PR30610.<br>
<br>
Reviewers: mehdi_amini<br>
<br>
Subscribers: johanengelen, krasin, llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D26146" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2614<wbr>6</a><br>
<br>
Added:<br>
llvm/trunk/test/ThinLTO/X86/In<wbr>puts/module_asm2.ll<br>
llvm/trunk/test/ThinLTO/X86/mo<wbr>dule_asm2.ll<br>
Modified:<br>
llvm/trunk/include/llvm/Suppor<wbr>t/TargetRegistry.h<br>
llvm/trunk/lib/Analysis/LLVMBu<wbr>ild.txt<br>
llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp<br>
llvm/trunk/lib/Bitcode/Writer/<wbr>BitcodeWriter.cpp<br>
llvm/trunk/lib/Object/IRObject<wbr>File.cpp<br>
llvm/trunk/test/LTO/X86/curren<wbr>t-section.ll<br>
llvm/trunk/tools/opt/opt.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Suppor<wbr>t/TargetRegistry.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Support/TargetRegistry.h?rev=2<wbr>86297&r1=286296&r2=286297&view<wbr>=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/Suppor<wbr>t/TargetRegistry.h (original)<br>
+++ llvm/trunk/include/llvm/Suppor<wbr>t/TargetRegistry.h Tue Nov 8 15:53:35 2016<br>
@@ -280,6 +280,9 @@ public:<br>
/// hasMCAsmBackend - Check if this target supports .o generation.<br>
bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }<br>
<br>
+ /// hasMCAsmParser - Check if this target supports assembly parsing.<br>
+ bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }<br>
+<br>
/// @}<br>
/// @name Feature Constructors<br>
/// @{<br>
<br>
Modified: llvm/trunk/lib/Analysis/LLVMBu<wbr>ild.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LLVMBuild.txt?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Analysis/<wbr>LLVMBuild.txt?rev=286297&r1=28<wbr>6296&r2=286297&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Analysis/LLVMBu<wbr>ild.txt (original)<br>
+++ llvm/trunk/lib/Analysis/LLVMBu<wbr>ild.txt Tue Nov 8 15:53:35 2016<br>
@@ -19,4 +19,4 @@<br>
type = Library<br>
name = Analysis<br>
parent = Libraries<br>
-required_libraries = Core Support ProfileData<br>
+required_libraries = Core Support ProfileData Object<br>
<br>
Modified: llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Analysis/<wbr>ModuleSummaryAnalysis.cpp?rev=<wbr>286297&r1=286296&r2=286297&vie<wbr>w=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp Tue Nov 8 15:53:35 2016<br>
@@ -13,6 +13,7 @@<br>
//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
<br>
#include "llvm/Analysis/ModuleSummaryAn<wbr>alysis.h"<br>
+#include "llvm/ADT/Triple.h"<br>
#include "llvm/Analysis/BlockFrequencyI<wbr>nfo.h"<br>
#include "llvm/Analysis/BlockFrequencyI<wbr>nfoImpl.h"<br>
#include "llvm/Analysis/BranchProbabili<wbr>tyInfo.h"<br>
@@ -24,6 +25,7 @@<br>
#include "llvm/IR/InstIterator.h"<br>
#include "llvm/IR/IntrinsicInst.h"<br>
#include "llvm/IR/ValueSymbolTable.h"<br>
+#include "llvm/Object/IRObjectFile.h"<br>
#include "llvm/Pass.h"<br>
using namespace llvm;<br>
<br>
@@ -194,12 +196,22 @@ ModuleSummaryIndex llvm::buildModuleSumm<br>
ProfileSummaryInfo *PSI) {<br>
ModuleSummaryIndex Index;<br>
<br>
- // Identify the local values in the llvm.used set, which should not be<br>
- // exported as they would then require renaming and promotion, but we<br>
- // may have opaque uses e.g. in inline asm.<br>
+ // Identify the local values in the llvm.used and llvm.compiler.used sets,<br>
+ // which should not be exported as they would then require renaming and<br>
+ // promotion, but we may have opaque uses e.g. in inline asm. We collect them<br>
+ // here because we use this information to mark functions containing inline<br>
+ // assembly calls as not importable.<br>
+ SmallPtrSet<GlobalValue *, 8> LocalsUsed;<br>
SmallPtrSet<GlobalValue *, 8> Used;<br>
+ // First collect those in the llvm.used set.<br>
collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false);<br>
- SmallPtrSet<GlobalValue *, 8> LocalsUsed;<br>
+ for (auto *V : Used) {<br>
+ if (V->hasLocalLinkage())<br>
+ LocalsUsed.insert(V);<br>
+ }<br>
+ Used.clear();<br>
+ // Next collect those in the llvm.compiler.used set.<br>
+ collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ true);<br>
for (auto *V : Used) {<br>
if (V->hasLocalLinkage())<br>
LocalsUsed.insert(V);<br>
@@ -244,6 +256,47 @@ ModuleSummaryIndex llvm::buildModuleSumm<br>
Summary->setNoRename();<br>
}<br>
<br>
+ if (!M.getModuleInlineAsm().empty<wbr>()) {<br>
+ // Collect the local values defined by module level asm, and set up<br>
+ // summaries for these symbols so that they can be marked as NoRename,<br>
+ // to prevent export of any use of them in regular IR that would require<br>
+ // renaming within the module level asm. Note we don't need to create a<br>
+ // summary for weak or global defs, as they don't need to be flagged as<br>
+ // NoRename, and defs in module level asm can't be imported anyway.<br>
+ // Also, any values used but not defined within module level asm should<br>
+ // be listed on the llvm.used or llvm.compiler.used global and marked as<br>
+ // referenced from there.<br>
+ // FIXME: Rename CollectAsmUndefinedRefs to something more general, as we<br>
+ // are also using it to find the file-scope locals defined in module asm.<br>
+ object::IRObjectFile::CollectA<wbr>smUndefinedRefs(<br>
+ Triple(M.getTargetTriple()), M.getModuleInlineAsm(),<br>
+ [&M, &Index](StringRef Name, object::BasicSymbolRef::Flags Flags) {<br>
+ // Symbols not marked as Weak or Global are local definitions.<br>
+ if (Flags & (object::BasicSymbolRef::SF_We<wbr>ak ||<br>
+ object::BasicSymbolRef::SF_Gl<wbr>obal))<br>
+ return;<br>
+ GlobalValue *GV = M.getNamedValue(Name);<br>
+ if (!GV)<br>
+ return;<br>
+ assert(GV->isDeclaration() && "Def in module asm already has definition");<br>
+ GlobalValueSummary::GVFlags GVFlags(GlobalValue::InternalL<wbr>inkage,<br>
+ /* NoRename */ true,<br>
+ /*IsNotViableToInline */ true);<br>
+ // Create the appropriate summary type.<br>
+ if (isa<Function>(GV)) {<br>
+ std::unique_ptr<FunctionSummar<wbr>y> Summary =<br>
+ llvm::make_unique<FunctionSumm<wbr>ary>(GVFlags, 0);<br>
+ Summary->setNoRename();<br>
+ Index.addGlobalValueSummary(Na<wbr>me, std::move(Summary));<br>
+ } else {<br>
+ std::unique_ptr<GlobalVarSumma<wbr>ry> Summary =<br>
+ llvm::make_unique<GlobalVarSum<wbr>mary>(GVFlags);<br>
+ Summary->setNoRename();<br>
+ Index.addGlobalValueSummary(Na<wbr>me, std::move(Summary));<br>
+ }<br>
+ });<br>
+ }<br>
+<br>
return Index;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Writer/<wbr>BitcodeWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Bitcode/W<wbr>riter/BitcodeWriter.cpp?rev=28<wbr>6297&r1=286296&r2=286297&view=<wbr>diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Bitcode/Writer/<wbr>BitcodeWriter.cpp (original)<br>
+++ llvm/trunk/lib/Bitcode/Writer/<wbr>BitcodeWriter.cpp Tue Nov 8 15:53:35 2016<br>
@@ -3327,11 +3327,16 @@ void ModuleBitcodeWriter::writePerM<wbr>odule<br>
void ModuleBitcodeWriter::writeModu<wbr>leLevelReferences(<br>
const GlobalVariable &V, SmallVector<uint64_t, 64> &NameVals,<br>
unsigned FSModRefsAbbrev) {<br>
- // Only interested in recording variable defs in the summary.<br>
- if (V.isDeclaration())<br>
+ auto Summaries =<br>
+ Index->findGlobalValueSummaryL<wbr>ist(GlobalValue::getGUID(V.get<wbr>Name()));<br>
+ if (Summaries == Index->end()) {<br>
+ // Only declarations should not have a summary (a declaration might however<br>
+ // have a summary if the def was in module level asm).<br>
+ assert(V.isDeclaration());<br>
return;<br>
+ }<br>
+ auto *Summary = Summaries->second.front().get(<wbr>);<br>
NameVals.push_back(VE.getValu<wbr>eID(&V));<br>
- auto *Summary = Index->getGlobalValueSummary(V<wbr>);<br>
GlobalVarSummary *VS = cast<GlobalVarSummary>(Summary<wbr>);<br>
NameVals.push_back(getEncoded<wbr>GVSummaryFlags(VS->flags()));<br>
<br>
@@ -3409,14 +3414,20 @@ void ModuleBitcodeWriter::writePerM<wbr>odule<br>
// Iterate over the list of functions instead of the Index to<br>
// ensure the ordering is stable.<br>
for (const Function &F : M) {<br>
- if (F.isDeclaration())<br>
- continue;<br>
// Summary emission does not support anonymous functions, they have to<br>
// renamed using the anonymous function renaming pass.<br>
if (!F.hasName())<br>
report_fatal_error("Unexpecte<wbr>d anonymous function when writing summary");<br>
<br>
- auto *Summary = Index->getGlobalValueSummary(F<wbr>);<br>
+ auto Summaries =<br>
+ Index->findGlobalValueSummaryL<wbr>ist(GlobalValue::getGUID(F.get<wbr>Name()));<br>
+ if (Summaries == Index->end()) {<br>
+ // Only declarations should not have a summary (a declaration might<br>
+ // however have a summary if the def was in module level asm).<br>
+ assert(F.isDeclaration());<br>
+ continue;<br>
+ }<br>
+ auto *Summary = Summaries->second.front().get(<wbr>);<br>
writePerModuleFunctionSummary<wbr>Record(NameVals, Summary, VE.getValueID(&F),<br>
FSCallsAbbrev, FSCallsProfileAbbrev, F);<br>
}<br>
<br>
Modified: llvm/trunk/lib/Object/IRObject<wbr>File.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Object/IR<wbr>ObjectFile.cpp?rev=286297&r1=2<wbr>86296&r2=286297&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Object/IRObject<wbr>File.cpp (original)<br>
+++ llvm/trunk/lib/Object/IRObject<wbr>File.cpp Tue Nov 8 15:53:35 2016<br>
@@ -54,8 +54,7 @@ void IRObjectFile::CollectAsmUndefi<wbr>nedRe<br>
<br>
std::string Err;<br>
const Target *T = TargetRegistry::lookupTarget(T<wbr>T.str(), Err);<br>
- if (!T)<br>
- return;<br>
+ assert(T && T->hasMCAsmParser());<br>
<br>
std::unique_ptr<MCRegisterInf<wbr>o> MRI(T->createMCRegInfo(TT.str(<wbr>)));<br>
if (!MRI)<br>
<br>
Modified: llvm/trunk/test/LTO/X86/curren<wbr>t-section.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/X86/current-section.ll?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/test/LTO/X86/<wbr>current-section.ll?rev=286297&<wbr>r1=286296&r2=286297&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/LTO/X86/curren<wbr>t-section.ll (original)<br>
+++ llvm/trunk/test/LTO/X86/curren<wbr>t-section.ll Tue Nov 8 15:53:35 2016<br>
@@ -2,4 +2,7 @@<br>
; RUN: llvm-lto -o %t2 %t1<br>
; REQUIRES: default_triple<br>
<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32<wbr>:64-S128"<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+<br>
module asm ".align 4"<br>
<br>
Added: llvm/trunk/test/ThinLTO/X86/In<wbr>puts/module_asm2.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/module_asm2.ll?rev=286297&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/test/ThinLTO/<wbr>X86/Inputs/module_asm2.ll?rev=<wbr>286297&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/ThinLTO/X86/In<wbr>puts/module_asm2.ll (added)<br>
+++ llvm/trunk/test/ThinLTO/X86/In<wbr>puts/module_asm2.ll Tue Nov 8 15:53:35 2016<br>
@@ -0,0 +1,12 @@<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32<wbr>:64-S128"<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+<br>
+define i32 @main({ i64, { i64, i8* }* } %unnamed) #0 {<br>
+ %1 = call i32 @func1() #1<br>
+ %2 = call i32 @func2() #1<br>
+ %3 = call i32 @func3() #1<br>
+ ret i32 %1<br>
+}<br>
+declare i32 @func1() #1<br>
+declare i32 @func2() #1<br>
+declare i32 @func3() #1<br>
<br>
Added: llvm/trunk/test/ThinLTO/X86/mo<wbr>dule_asm2.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/module_asm2.ll?rev=286297&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/test/ThinLTO/<wbr>X86/module_asm2.ll?rev=286297&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/ThinLTO/X86/mo<wbr>dule_asm2.ll (added)<br>
+++ llvm/trunk/test/ThinLTO/X86/mo<wbr>dule_asm2.ll Tue Nov 8 15:53:35 2016<br>
@@ -0,0 +1,84 @@<br>
+; Test to ensure that uses and defs in module level asm are handled<br>
+; appropriately. Specifically, we should conservatively block importing<br>
+; of any references to these values, as they can't be renamed.<br>
+; RUN: opt -module-summary %s -o %t1.bc<br>
+; RUN: opt -module-summary %p/Inputs/module_asm2.ll -o %t2.bc<br>
+<br>
+; RUN: llvm-lto -thinlto-action=run -exported-symbol=main -exported-symbol=func1 -exported-symbol=func2 -exported-symbol=func3 %t1.bc %t2.bc<br>
+; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM0<br>
+; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s --check-prefix=NM1<br>
+<br>
+; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.o -save-temps \<br>
+; RUN: -r=%t1.bc,foo,plx \<br>
+; RUN: -r=%t1.bc,b,pl \<br>
+; RUN: -r=%t1.bc,x,pl \<br>
+; RUN: -r=%t1.bc,func1,pl \<br>
+; RUN: -r=%t1.bc,func2,pl \<br>
+; RUN: -r=%t1.bc,func3,pl \<br>
+; RUN: -r=%t2.bc,main,plx \<br>
+; RUN: -r=%t2.bc,func1,l \<br>
+; RUN: -r=%t2.bc,func2,l \<br>
+; RUN: -r=%t2.bc,func3,l<br>
+; RUN: llvm-nm %t.o.0 | FileCheck %s --check-prefix=NM0<br>
+; RUN: llvm-nm %t.o.1 | FileCheck %s --check-prefix=NM1<br>
+<br>
+; Check that local values b and x, which are referenced on<br>
+; llvm.used and llvm.compiler.used, respectively, are not promoted.<br>
+; Similarly, foo which is defined in module level asm should not be<br>
+; promoted.<br>
+; NM0-DAG: d b<br>
+; NM0-DAG: d x<br>
+; NM0-DAG: t foo<br>
+; NM0-DAG: T func1<br>
+; NM0-DAG: T func2<br>
+; NM0-DAG: T func3<br>
+<br>
+; Ensure that foo, b and x are likewise not exported (imported as refs<br>
+; into the other module), since they can't be promoted. Additionally,<br>
+; referencing functions func1, func2 and func3 should not have been<br>
+; imported.<br>
+; NM1-NOT: foo<br>
+; NM1-NOT: b<br>
+; NM1-NOT: x<br>
+; NM1-DAG: U func1<br>
+; NM1-DAG: U func2<br>
+; NM1-DAG: U func3<br>
+; NM1-DAG: T main<br>
+; NM1-NOT: foo<br>
+; NM1-NOT: b<br>
+; NM1-NOT: x<br>
+<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32<wbr>:64-S128"<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+<br>
+@b = internal global i32 1, align 4<br>
+@x = internal global i32 1, align 4<br>
+<br>
+@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32* @b to i8*)], section "llvm.metadata"<br>
+@llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @x to i8*)], section "llvm.metadata"<br>
+<br>
+module asm "\09.text"<br>
+module asm "\09.type\09foo,@function"<br>
+module asm "foo:"<br>
+module asm "\09movl b, %eax"<br>
+module asm "\09movl x, %edx"<br>
+module asm "\09ret "<br>
+module asm "\09.size\09foo, .-foo"<br>
+module asm ""<br>
+<br>
+declare i16 @foo() #0<br>
+<br>
+define i32 @func1() #1 {<br>
+ call i16 @foo()<br>
+ ret i32 1<br>
+}<br>
+<br>
+define i32 @func2() #1 {<br>
+ %1 = load i32, i32* @b, align 4<br>
+ ret i32 %1<br>
+}<br>
+<br>
+define i32 @func3() #1 {<br>
+ %1 = load i32, i32* @x, align 4<br>
+ ret i32 %1<br>
+}<br>
<br>
Modified: llvm/trunk/tools/opt/opt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=286297&r1=286296&r2=286297&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/tools/opt/opt<wbr>.cpp?rev=286297&r1=286296&r2=2<wbr>86297&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/tools/opt/opt.cpp (original)<br>
+++ llvm/trunk/tools/opt/opt.cpp Tue Nov 8 15:53:35 2016<br>
@@ -364,6 +364,7 @@ int main(int argc, char **argv) {<br>
InitializeAllTargets();<br>
InitializeAllTargetMCs();<br>
InitializeAllAsmPrinters();<br>
+ InitializeAllAsmParsers();<br>
<br>
// Initialize passes<br>
PassRegistry &Registry = *PassRegistry::getPassRegistry<wbr>();<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-7316144437542370060gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div>