[CodeGen][GC] Initialize roots with Constant::getNullValue() instead of ConstantPointerNull::get() (#199367)
Fixes #199219
This commit is contained in:
parent
ab1745439c
commit
11f0e7768b
2 changed files with 28 additions and 3 deletions
|
|
@ -177,9 +177,8 @@ static bool InsertRootInitializers(Function &F, ArrayRef<AllocaInst *> Roots) {
|
|||
|
||||
for (AllocaInst *Root : Roots)
|
||||
if (!InitedRoots.count(Root)) {
|
||||
new StoreInst(
|
||||
ConstantPointerNull::get(cast<PointerType>(Root->getAllocatedType())),
|
||||
Root, std::next(Root->getIterator()));
|
||||
new StoreInst(Constant::getNullValue(Root->getAllocatedType()), Root,
|
||||
std::next(Root->getIterator()));
|
||||
MadeChange = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,3 +60,29 @@ define void @no_gc() {
|
|||
;
|
||||
ret void
|
||||
}
|
||||
|
||||
@metadata = constant i32 0
|
||||
|
||||
define void @non_ptr_alloca_root() gc "shadow-stack" {
|
||||
; CHECK-LABEL: define void @non_ptr_alloca_root() gc "shadow-stack" {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: %A = alloca double, align 8
|
||||
; CHECK-NEXT: store double 0.000000e+00, ptr %A, align 8
|
||||
; CHECK-NEXT: %B = alloca { double, double }, align 8
|
||||
; CHECK-NEXT: store { double, double } zeroinitializer, ptr %B, align 8
|
||||
; CHECK-NEXT: call void @llvm.gcroot(ptr %A, ptr @metadata)
|
||||
; CHECK-NEXT: call void @llvm.gcroot(ptr %B, ptr @metadata)
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK-NEXT: }
|
||||
entry:
|
||||
%A = alloca double
|
||||
%B = alloca { double, double }
|
||||
|
||||
;; ptr A;
|
||||
call void @llvm.gcroot(ptr %A, ptr @metadata)
|
||||
|
||||
;; ptr B;
|
||||
call void @llvm.gcroot(ptr %B, ptr @metadata)
|
||||
|
||||
ret void
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue