http://llvm.org/bugs/show_bug.cgi?id=21592

            Bug ID: 21592
           Summary: GlobalOpt::CleanupPointerRootUsers could pass nullptr
                    to dyn_cast
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 13358
  --> http://llvm.org/bugs/attachment.cgi?id=13358&action=edit
Proposed patch

https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/IPO/GlobalOpt.cpp#L222
:

222: GlobalVariable *MemSrc = dyn_cast<GlobalVariable>(MTI->getSource());
223: if (MemSrc && MemSrc->isConstant()) {
224:     Changed = true;
225:     MTI->eraseFromParent();
226: } else if (Instruction *I = dyn_cast<Instruction>(MemSrc)) {
227:     if (I->hasOneUse())
228:     Dead.push_back(std::make_pair(I, MTI));
229: }

if MTI->getSource() is an Instruction, dyn_cast(222) returns nullptr, so  the
condition (223) would be false, and dyn_cast (226) would fail due to MemSrc
being null. 

Probably, the author meant that dyn_cast (226) should use the return of
MTI->getSource(). In this case, the attached patch fixes the issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to