Leonard Chan 94382c8e56 [llvm][StackProtector] Add noreturn to __stack_chk_fail call (#143976)
This is a reland for 99e53cb4139eda491f97cb33ee42ea424d352200 with the
appropriate test fixes.

It's possible for __stack_chk_fail to be an alias when using CrossDSOCFI
since it will make a jump table entry for this function and replace it
with an alias. StackProtector can crash since it always expects this to
be a regular function. Instead add the noreturn attribute to the call.
2025-07-16 13:12:28 -07:00

23 lines
653 B
LLVM

;; __stack_chk_fail should have the noreturn attr even if it is an alias
; REQUIRES: x86-registered-target
; RUN: opt -mtriple=x86_64-pc-linux-gnu %s -passes=stack-protector -S | FileCheck %s
define hidden void @__stack_chk_fail_impl() {
unreachable
}
@__stack_chk_fail = hidden alias void (), ptr @__stack_chk_fail_impl
; CHECK-LABEL: @store_captures(
; CHECK: CallStackCheckFailBlk:
; CHECK-NEXT: call void @__stack_chk_fail() [[ATTRS:#.*]]
define void @store_captures() sspstrong {
entry:
%a = alloca i32, align 4
%j = alloca ptr, align 8
store ptr %a, ptr %j, align 8
ret void
}
; CHECK: attributes [[ATTRS]] = { noreturn }