1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[WebAssembly] Fix crash when @llvm.global_dtors is external

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58799

llvm-svn: 355157
This commit is contained in:
Thomas Lively 2019-03-01 00:12:13 +00:00
parent f84f2517d5
commit 24389ccbc7
2 changed files with 10 additions and 1 deletions

View File

@ -61,7 +61,7 @@ bool LowerGlobalDtors::runOnModule(Module &M) {
LLVM_DEBUG(dbgs() << "********** Lower Global Destructors **********\n");
GlobalVariable *GV = M.getGlobalVariable("llvm.global_dtors");
if (!GV)
if (!GV || !GV->hasInitializer())
return false;
const ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());

View File

@ -0,0 +1,9 @@
; RUN: llc < %s
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
; Check that we do not crash when attempting to lower away
; global_dtors without a definition.
@llvm.global_dtors = external global [2 x { i32, void ()*, i8* }]