[LLVMbugs] [Bug 21592] New: GlobalOpt::CleanupPointerRootUsers could pass nullptr to dyn_cast

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 17 09:08:35 PST 2014


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: unassignedbugs at nondot.org
          Reporter: vedun at ispras.ru
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141117/cc1233dd/attachment.html>


More information about the llvm-bugs mailing list