<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - GlobalOpt asserts with "Should be GlobalVariable""
   href="https://bugs.llvm.org/show_bug.cgi?id=51608">51608</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>GlobalOpt asserts with "Should be GlobalVariable"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alina.sbirlea@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproduces with "opt -passes=globalopt test.ll" on:

%sometype = type { i8* }

@map = internal unnamed_addr global %sometype* null, align 8

define void @Init() {
entry:
  %call = tail call noalias nonnull dereferenceable(48) i8* @_Znwm(i64 48)
  store i8* %call, i8** bitcast (%sometype** @map to i8**), align 8
  ret void
}

define void @Usage() {
entry:
  %0 = load i8*, i8** bitcast (%sometype** @map to i8**), align 8
  %.not = icmp eq i8* %0, null
  unreachable
}

declare i8* @_Znwm(i64)

Assertion details:
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:708: bool
AllUsesOfValueWillTrapIfNull(const llvm::Value *, SmallPtrSetImpl<const
llvm::PHINode *> &): Assertion `isa<GlobalValue>(
cast<LoadInst>(U->getOperand(0))->getPointerOperand()) && "Should be
GlobalVariable"' failed.

[...]
#10 0x000000000747c411 AllUsesOfValueWillTrapIfNull(llvm::Value const*,
llvm::SmallPtrSetImpl<llvm::PHINode const*>&)
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:712:5
#11 0x000000000747b11a allUsesOfLoadedValueWillTrapIfNull(llvm::GlobalVariable
const*) llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:731:13
#12 0x000000000747a9fa
tryToOptimizeStoreOfMallocToGlobal(llvm::GlobalVariable*, llvm::CallInst*,
llvm::Type*, llvm::AtomicOrdering, llvm::DataLayout const&,
llvm::TargetLibraryInfo*)
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:1118:7
#13 0x00000000074784b4 optimizeOnceStoredGlobal(llvm::GlobalVariable*,
llvm::Value*, llvm::AtomicOrdering, llvm::DataLayout const&,
llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>)
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:1178:11
#14 0x0000000007475758 processInternalGlobal(llvm::GlobalVariable*,
llvm::GlobalStatus const&, llvm::function_ref<llvm::TargetLibraryInfo&
(llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>)
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:1633:9
#15 0x0000000007473c20 processGlobal(llvm::GlobalValue&,
llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>,
llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>)
llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:1688:65
[...]</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>