[PATCH] D125584: [GlobalIsel] Fix fallback if stack protector isn't supported.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 13 13:43:32 PDT 2022
efriedma created this revision.
efriedma added reviewers: aemerson, paquette.
Herald added subscribers: hiraditya, rovka.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: LLVM.
When GlobalISel fails, we need to report the error, and we need to set the FailedISel property. We skipped those steps if stack protector insertion failed, which led to a very strange miscompile.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125584
Files:
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-stack-protector-windows.ll
Index: llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-stack-protector-windows.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-stack-protector-windows.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=aarch64-pc-windows-msvc %s -o - -global-isel -global-isel-abort=0 | FileCheck %s
+
+; Make sure we correctly fall back to SelectionDAG isel for unsupported stack protectors.
+
+define void @caller() sspreq {
+; CHECK-LABEL: caller:
+; CHECK: .seh_proc caller
+; CHECK-NEXT: // %bb.0: // %entry
+; CHECK-NEXT: sub sp, sp, #32
+; CHECK-NEXT: .seh_stackalloc 32
+; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
+; CHECK-NEXT: .seh_save_reg x30, 16
+; CHECK-NEXT: .seh_endprologue
+; CHECK-NEXT: adrp x8, __security_cookie
+; CHECK-NEXT: add x0, sp, #4
+; CHECK-NEXT: ldr x8, [x8, :lo12:__security_cookie]
+; CHECK-NEXT: str x8, [sp, #8]
+; CHECK-NEXT: bl callee
+; CHECK-NEXT: ldr x0, [sp, #8]
+; CHECK-NEXT: bl __security_check_cookie
+; CHECK-NEXT: .seh_startepilogue
+; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
+; CHECK-NEXT: .seh_save_reg x30, 16
+; CHECK-NEXT: add sp, sp, #32
+; CHECK-NEXT: .seh_stackalloc 32
+; CHECK-NEXT: .seh_endepilogue
+; CHECK-NEXT: ret
+; CHECK-NEXT: .seh_endfunclet
+; CHECK-NEXT: .seh_endproc
+entry:
+ %x = alloca i32, align 4
+ %0 = bitcast i32* %x to i8*
+ call void @callee(i32* nonnull %x)
+ ret void
+}
+
+declare void @callee(i32*)
Index: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3484,8 +3484,13 @@
return false;
}
- if (!finalizeBasicBlock(*BB, MBB))
+ if (!finalizeBasicBlock(*BB, MBB)) {
+ OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure",
+ BB->getTerminator()->getDebugLoc(), BB);
+ R << "unable to translate basic block";
+ reportTranslationError(*MF, *TPC, *ORE, R);
return false;
+ }
}
#ifndef NDEBUG
WrapperObserver.removeObserver(&Verifier);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125584.429345.patch
Type: text/x-patch
Size: 2368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220513/84a0ce95/attachment.bin>
More information about the llvm-commits
mailing list