mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 21:41:43 +00:00
Handle ConstantAggregateZero when upgrading global_ctors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fbd8cc0926
commit
e7a6c2f1df
@ -191,16 +191,19 @@ static bool UpgradeGlobalStructors(GlobalVariable *GV) {
|
|||||||
StructType::get(GV->getContext(), Tys, /*isPacked=*/false);
|
StructType::get(GV->getContext(), Tys, /*isPacked=*/false);
|
||||||
|
|
||||||
// Build new constants with a null third field filled in.
|
// Build new constants with a null third field filled in.
|
||||||
ConstantArray *OldInit = dyn_cast<ConstantArray>(GV->getInitializer());
|
Constant *OldInitC = GV->getInitializer();
|
||||||
if (!OldInit)
|
ConstantArray *OldInit = dyn_cast<ConstantArray>(OldInitC);
|
||||||
|
if (!OldInit && !isa<ConstantAggregateZero>(OldInitC))
|
||||||
return false;
|
return false;
|
||||||
std::vector<Constant *> Initializers;
|
std::vector<Constant *> Initializers;
|
||||||
for (Use &U : OldInit->operands()) {
|
if (OldInit) {
|
||||||
ConstantStruct *Init = cast<ConstantStruct>(&U);
|
for (Use &U : OldInit->operands()) {
|
||||||
Constant *NewInit =
|
ConstantStruct *Init = cast<ConstantStruct>(&U);
|
||||||
|
Constant *NewInit =
|
||||||
ConstantStruct::get(NewTy, Init->getOperand(0), Init->getOperand(1),
|
ConstantStruct::get(NewTy, Init->getOperand(0), Init->getOperand(1),
|
||||||
Constant::getNullValue(VoidPtrTy), nullptr);
|
Constant::getNullValue(VoidPtrTy), nullptr);
|
||||||
Initializers.push_back(NewInit);
|
Initializers.push_back(NewInit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert(Initializers.size() == ATy->getNumElements());
|
assert(Initializers.size() == ATy->getNumElements());
|
||||||
|
|
||||||
|
3
test/Bitcode/upgrade-global-ctors.ll
Normal file
3
test/Bitcode/upgrade-global-ctors.ll
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
; RUN: llvm-dis < %s.bc| FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer
|
BIN
test/Bitcode/upgrade-global-ctors.ll.bc
Normal file
BIN
test/Bitcode/upgrade-global-ctors.ll.bc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user