[llvm] [CodeGen][ARM64EC] Don't treat guest exit thunks as indirect calls (PR #165885)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 11:12:12 PDT 2025


================
@@ -0,0 +1,89 @@
+; REQUIRES: aarch64-registered-target
+; RUN: llc < %s -mtriple=arm64ec-windows | FileCheck %s
+
+; This file was generated from the following source, using this command line:
+; clang -target arm64ec-windows cfguard-arm64ec.c -S -emit-llvm -o cfguard-arm64ec.ll -O -Xclang -cfguard
+;
+;-------------------------------------------------------------------------------
+; extern void ext(void);
+;
+; void func(void (*f)())
+; {
+;     ext();
+;     f();
+; }
+;-------------------------------------------------------------------------------
+
+; ModuleID = 'cfguard-arm64ec.c'
+source_filename = "cfguard-arm64ec.c"
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32"
+target triple = "arm64ec-unknown-windows-msvc19.33.0"
+
+; CHECK: "@feat.00" = 2048
+
+; Function Attrs: nounwind uwtable
+define dso_local void @func(ptr noundef readonly captures(none) %f) local_unnamed_addr #0 {
+entry:
+  tail call void @ext() #2
+; CHECK:  bl   "#ext"
+  tail call void %f() #2
+; CHECK-NEXT:  adrp    x8, __os_arm64x_check_icall_cfg
+; CHECK-NEXT:  adrp    x10, $iexit_thunk$cdecl$v$v
+; CHECK-NEXT:  add     x10, x10, :lo12:$iexit_thunk$cdecl$v$v
+; CHECK-NEXT:  ldr     x8, [x8, :lo12:__os_arm64x_check_icall_cfg]
----------------
efriedma-quic wrote:

I somehow missed adding a test for this when I originally implemented it?  In any case, thanks for adding it.

Do we want to combine this test file with llvm/test/CodeGen/AArch64/cfguard-arm64ec.ll ?

https://github.com/llvm/llvm-project/pull/165885


More information about the llvm-commits mailing list