[clang] [clang] Remove isOSWindows() checks (PR #129909)

2025-04-14 Thread Prabhu Rajasekaran via cfe-commits

Prabhuk wrote:

@rnk @mstorsjo -- Can you please take a look at the changes? 

https://github.com/llvm/llvm-project/pull/129909
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-18 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/127290

>From 3e6122744f355954edb6a5450ae4220ba39bc9c1 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Fri, 14 Feb 2025 16:53:33 -0800
Subject: [PATCH 01/14] [clang] Fix UEFI Target info

For X64 UEFI targets, making the integer size and va_list kind fixes.
---
 clang/include/clang/Basic/TargetOSMacros.def |  3 +++
 clang/lib/Basic/Targets/X86.h| 16 +++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/Basic/TargetOSMacros.def 
b/clang/include/clang/Basic/TargetOSMacros.def
index 58dce330f9c8f..f4f3276ad1c25 100644
--- a/clang/include/clang/Basic/TargetOSMacros.def
+++ b/clang/include/clang/Basic/TargetOSMacros.def
@@ -53,4 +53,7 @@ TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
 TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment())
 TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment())
 
+// UEFI target.
+TARGET_OS(TARGET_OS_UEFI, Triple.isUEFI())
+
 #undef TARGET_OS
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 205edcab9ccb3..20fcb25defba2 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -835,16 +835,22 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
 public:
   UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : UEFITargetInfo(Triple, Opts) {
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
+SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+WCharType = UnsignedShort;
+WIntType = UnsignedShort;
 this->TheCXXABI.set(TargetCXXABI::Microsoft);
-this->MaxTLSAlign = 8192u * this->getCharWidth();
 this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-"
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  BuiltinVaListKind getBuiltinVaListKind() const override {
-return TargetInfo::CharPtrBuiltinVaList;
-  }
-
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 switch (CC) {
 case CC_C:

>From fa23204cb0eb6826f8866e497ff4d6ed96dbb8df Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 26 Feb 2025 09:59:47 -0800
Subject: [PATCH 02/14] More cleanups. Add test.

---
 clang/lib/Basic/Targets/X86.h  | 10 --
 clang/test/Preprocessor/init.c |  1 +
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 20fcb25defba2..be07ae05f326c 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,16 +851,6 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
-switch (CC) {
-case CC_C:
-case CC_Win64:
-  return CCCR_OK;
-default:
-  return CCCR_Warning;
-}
-  }
-
   TargetInfo::CallingConvKind
   getCallingConvKind(bool ClangABICompat4) const override {
 return CCK_MicrosoftWin64;
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 1ac325d444662..4c8d519c2b664 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -2835,6 +2835,7 @@
 // RISCV64-LINUX: #define unix 1
 
 // RUN: %clang_cc1 -dM -triple=x86_64-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
+// RUN: %clang_cc1 -dM -triple=x86_64-unknown-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
 
 // UEFI: #define __UEFI__ 1
 

>From 6305ac501a8b862486de7ea551ff77ff49d91dac Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 5 Mar 2025 18:14:04 +
Subject: [PATCH 03/14] Include all allowed callingconventions in
 checkCallingConvention

---
 clang/lib/Basic/Targets/X86.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index be07ae05f326c..58753e0c4d904 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,6 +851,30 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_X86StdCall:
+case CC_X86ThisCall:
+case CC_X86FastCall:
+  return CCCR_Ignore;
+case CC_C:
+case CC_X86VectorCall:
+case CC_IntelOclBicc:
+case CC_PreserveMost:
+case CC_PreserveAll:
+case CC_PreserveNone:
+case CC_X86_64SysV:
+case CC_Swift:
+case CC_SwiftAsync:
+case CC_X86RegCall:
+case CC_OpenCLKernel:
+case CC_Win64:
+  

[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-18 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/127290

>From 3e6122744f355954edb6a5450ae4220ba39bc9c1 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Fri, 14 Feb 2025 16:53:33 -0800
Subject: [PATCH 01/13] [clang] Fix UEFI Target info

For X64 UEFI targets, making the integer size and va_list kind fixes.
---
 clang/include/clang/Basic/TargetOSMacros.def |  3 +++
 clang/lib/Basic/Targets/X86.h| 16 +++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/Basic/TargetOSMacros.def 
b/clang/include/clang/Basic/TargetOSMacros.def
index 58dce330f9c8f..f4f3276ad1c25 100644
--- a/clang/include/clang/Basic/TargetOSMacros.def
+++ b/clang/include/clang/Basic/TargetOSMacros.def
@@ -53,4 +53,7 @@ TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
 TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment())
 TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment())
 
+// UEFI target.
+TARGET_OS(TARGET_OS_UEFI, Triple.isUEFI())
+
 #undef TARGET_OS
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 205edcab9ccb3..20fcb25defba2 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -835,16 +835,22 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
 public:
   UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : UEFITargetInfo(Triple, Opts) {
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
+SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+WCharType = UnsignedShort;
+WIntType = UnsignedShort;
 this->TheCXXABI.set(TargetCXXABI::Microsoft);
-this->MaxTLSAlign = 8192u * this->getCharWidth();
 this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-"
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  BuiltinVaListKind getBuiltinVaListKind() const override {
-return TargetInfo::CharPtrBuiltinVaList;
-  }
-
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 switch (CC) {
 case CC_C:

>From fa23204cb0eb6826f8866e497ff4d6ed96dbb8df Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 26 Feb 2025 09:59:47 -0800
Subject: [PATCH 02/13] More cleanups. Add test.

---
 clang/lib/Basic/Targets/X86.h  | 10 --
 clang/test/Preprocessor/init.c |  1 +
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 20fcb25defba2..be07ae05f326c 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,16 +851,6 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
-switch (CC) {
-case CC_C:
-case CC_Win64:
-  return CCCR_OK;
-default:
-  return CCCR_Warning;
-}
-  }
-
   TargetInfo::CallingConvKind
   getCallingConvKind(bool ClangABICompat4) const override {
 return CCK_MicrosoftWin64;
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 1ac325d444662..4c8d519c2b664 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -2835,6 +2835,7 @@
 // RISCV64-LINUX: #define unix 1
 
 // RUN: %clang_cc1 -dM -triple=x86_64-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
+// RUN: %clang_cc1 -dM -triple=x86_64-unknown-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
 
 // UEFI: #define __UEFI__ 1
 

>From 6305ac501a8b862486de7ea551ff77ff49d91dac Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 5 Mar 2025 18:14:04 +
Subject: [PATCH 03/13] Include all allowed callingconventions in
 checkCallingConvention

---
 clang/lib/Basic/Targets/X86.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index be07ae05f326c..58753e0c4d904 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,6 +851,30 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_X86StdCall:
+case CC_X86ThisCall:
+case CC_X86FastCall:
+  return CCCR_Ignore;
+case CC_C:
+case CC_X86VectorCall:
+case CC_IntelOclBicc:
+case CC_PreserveMost:
+case CC_PreserveAll:
+case CC_PreserveNone:
+case CC_X86_64SysV:
+case CC_Swift:
+case CC_SwiftAsync:
+case CC_X86RegCall:
+case CC_OpenCLKernel:
+case CC_Win64:
+  

[clang] [NFC][clang] No sharedlibs for UEFI (PR #137872)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/137872

>From 60473fc01469167d742cee1fcdc1b05b93482f94 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:21:16 -0700
Subject: [PATCH] [NFC][clang] No sharedlibs for UEFI

There is no support for shared libraries for UEFI target. Remove the
incorrect -dll flag set from UEFI toolchain.
---
 clang/lib/Driver/ToolChains/UEFI.cpp  | 3 ---
 clang/test/Driver/uefi-constructed-args.c | 1 -
 2 files changed, 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/UEFI.cpp 
b/clang/lib/Driver/ToolChains/UEFI.cpp
index a9d7e7892c5a6..fbef72e34a3b1 100644
--- a/clang/lib/Driver/ToolChains/UEFI.cpp
+++ b/clang/lib/Driver/ToolChains/UEFI.cpp
@@ -80,9 +80,6 @@ void tools::uefi::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // "Terminal Service Aware" flag is not needed for UEFI applications.
   CmdArgs.push_back("-tsaware:no");
 
-  // EFI_APPLICATION to be linked as DLL by default.
-  CmdArgs.push_back("-dll");
-
   if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
diff --git a/clang/test/Driver/uefi-constructed-args.c 
b/clang/test/Driver/uefi-constructed-args.c
index 44d2271e0c8ba..49ede47a8953e 100644
--- a/clang/test/Driver/uefi-constructed-args.c
+++ b/clang/test/Driver/uefi-constructed-args.c
@@ -11,5 +11,4 @@
 // CHECK-SAME: "-subsystem:efi_application"
 // CHECK-SAME: "-entry:EfiMain"
 // CHECK-SAME: "-tsaware:no"
-// CHECK-SAME: "-dll"
 // CHECK-SAME: "-debug"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/137874

>From 45778ad1a6cd0d7ce6333f6e8b69d4f4138b962e Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:43:32 -0700
Subject: [PATCH] [nfc][clang] Rename function

Rename function to meet the coding guidelines. I am working on a similar
function in a subsequent PR. Landing this as NFC first to isolate this
change.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 6 +++---
 clang/lib/CodeGen/CodeGenModule.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e917f3c42da06..447204d6c23af 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2661,7 +2661,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const 
NamedDecl *ND) {
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   // Only if we are checking indirect calls.
   if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
@@ -3016,7 +3016,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 59f400570fb7a..1db5c3bc4e4ef 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1633,7 +1633,7 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Set type metadata to the given function.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-30 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk closed 
https://github.com/llvm/llvm-project/pull/127290
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-30 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk closed 
https://github.com/llvm/llvm-project/pull/137874
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/127290

>From 3e6122744f355954edb6a5450ae4220ba39bc9c1 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Fri, 14 Feb 2025 16:53:33 -0800
Subject: [PATCH 01/15] [clang] Fix UEFI Target info

For X64 UEFI targets, making the integer size and va_list kind fixes.
---
 clang/include/clang/Basic/TargetOSMacros.def |  3 +++
 clang/lib/Basic/Targets/X86.h| 16 +++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/Basic/TargetOSMacros.def 
b/clang/include/clang/Basic/TargetOSMacros.def
index 58dce330f9c8f..f4f3276ad1c25 100644
--- a/clang/include/clang/Basic/TargetOSMacros.def
+++ b/clang/include/clang/Basic/TargetOSMacros.def
@@ -53,4 +53,7 @@ TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
 TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment())
 TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment())
 
+// UEFI target.
+TARGET_OS(TARGET_OS_UEFI, Triple.isUEFI())
+
 #undef TARGET_OS
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 205edcab9ccb3..20fcb25defba2 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -835,16 +835,22 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
 public:
   UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : UEFITargetInfo(Triple, Opts) {
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
+SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+WCharType = UnsignedShort;
+WIntType = UnsignedShort;
 this->TheCXXABI.set(TargetCXXABI::Microsoft);
-this->MaxTLSAlign = 8192u * this->getCharWidth();
 this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-"
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  BuiltinVaListKind getBuiltinVaListKind() const override {
-return TargetInfo::CharPtrBuiltinVaList;
-  }
-
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 switch (CC) {
 case CC_C:

>From fa23204cb0eb6826f8866e497ff4d6ed96dbb8df Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 26 Feb 2025 09:59:47 -0800
Subject: [PATCH 02/15] More cleanups. Add test.

---
 clang/lib/Basic/Targets/X86.h  | 10 --
 clang/test/Preprocessor/init.c |  1 +
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 20fcb25defba2..be07ae05f326c 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,16 +851,6 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
-  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
-switch (CC) {
-case CC_C:
-case CC_Win64:
-  return CCCR_OK;
-default:
-  return CCCR_Warning;
-}
-  }
-
   TargetInfo::CallingConvKind
   getCallingConvKind(bool ClangABICompat4) const override {
 return CCK_MicrosoftWin64;
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 1ac325d444662..4c8d519c2b664 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -2835,6 +2835,7 @@
 // RISCV64-LINUX: #define unix 1
 
 // RUN: %clang_cc1 -dM -triple=x86_64-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
+// RUN: %clang_cc1 -dM -triple=x86_64-unknown-uefi -E /dev/null | FileCheck 
-match-full-lines -check-prefix UEFI %s
 
 // UEFI: #define __UEFI__ 1
 

>From 6305ac501a8b862486de7ea551ff77ff49d91dac Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 5 Mar 2025 18:14:04 +
Subject: [PATCH 03/15] Include all allowed callingconventions in
 checkCallingConvention

---
 clang/lib/Basic/Targets/X86.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index be07ae05f326c..58753e0c4d904 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -851,6 +851,30 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
   "i64:64-i128:128-f80:128-n8:16:32:64-S128");
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_X86StdCall:
+case CC_X86ThisCall:
+case CC_X86FastCall:
+  return CCCR_Ignore;
+case CC_C:
+case CC_X86VectorCall:
+case CC_IntelOclBicc:
+case CC_PreserveMost:
+case CC_PreserveAll:
+case CC_PreserveNone:
+case CC_X86_64SysV:
+case CC_Swift:
+case CC_SwiftAsync:
+case CC_X86RegCall:
+case CC_OpenCLKernel:
+case CC_Win64:
+  

[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits


@@ -3038,8 +3038,30 @@ static Address EmitX86_64VAArgFromMemory(CodeGenFunction 
&CGF,
   return Address(Res, LTy, Align);
 }
 
+static RValue EmitMSABIVAArg(CodeGenFunction &CGF, Address VAListAddr,
+ QualType Ty, AggValueSlot Slot,
+ ASTContext &context) {
+  // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
+  // not 1, 2, 4, or 8 bytes, must be passed by reference."
+  uint64_t Width = context.getTypeSize(Ty);
+  bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width);
+
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false, Slot);
+}
+
 RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty, AggValueSlot Slot) const {
+
+  // Emit MS ABI compliant va_list for X86_64 targets which use Microsoft CXX
+  // ABI and CharPtrBuiltinVaList.
+  if (CGF.getTarget().getCXXABI().isMicrosoft() &&
+  CGF.getTarget().getBuiltinVaListKind() ==
+  clang::TargetInfo::CharPtrBuiltinVaList)
+return EmitMSABIVAArg(CGF, VAListAddr, Ty, Slot, getContext());

Prabhuk wrote:

Changed the code to address the comment as suggested based on the offline 
discussion. 

https://github.com/llvm/llvm-project/pull/127290
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][clang] No sharedlibs for UEFI (PR #137872)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk created 
https://github.com/llvm/llvm-project/pull/137872

There is no support for shared libraries for UEFI target. Remove the
incorrect -dll flag set from UEFI toolchain.


>From 60473fc01469167d742cee1fcdc1b05b93482f94 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:21:16 -0700
Subject: [PATCH] [NFC][clang] No sharedlibs for UEFI

There is no support for shared libraries for UEFI target. Remove the
incorrect -dll flag set from UEFI toolchain.
---
 clang/lib/Driver/ToolChains/UEFI.cpp  | 3 ---
 clang/test/Driver/uefi-constructed-args.c | 1 -
 2 files changed, 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/UEFI.cpp 
b/clang/lib/Driver/ToolChains/UEFI.cpp
index a9d7e7892c5a6..fbef72e34a3b1 100644
--- a/clang/lib/Driver/ToolChains/UEFI.cpp
+++ b/clang/lib/Driver/ToolChains/UEFI.cpp
@@ -80,9 +80,6 @@ void tools::uefi::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // "Terminal Service Aware" flag is not needed for UEFI applications.
   CmdArgs.push_back("-tsaware:no");
 
-  // EFI_APPLICATION to be linked as DLL by default.
-  CmdArgs.push_back("-dll");
-
   if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
diff --git a/clang/test/Driver/uefi-constructed-args.c 
b/clang/test/Driver/uefi-constructed-args.c
index 44d2271e0c8ba..49ede47a8953e 100644
--- a/clang/test/Driver/uefi-constructed-args.c
+++ b/clang/test/Driver/uefi-constructed-args.c
@@ -11,5 +11,4 @@
 // CHECK-SAME: "-subsystem:efi_application"
 // CHECK-SAME: "-entry:EfiMain"
 // CHECK-SAME: "-tsaware:no"
-// CHECK-SAME: "-dll"
 // CHECK-SAME: "-debug"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk created 
https://github.com/llvm/llvm-project/pull/137874

Rename function to meet the coding guidelines. I am working on a similar
function in a subsequent PR. Landing this as NFC first to isolate this
change.


>From 45778ad1a6cd0d7ce6333f6e8b69d4f4138b962e Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:43:32 -0700
Subject: [PATCH] [nfc][clang] Rename function

Rename function to meet the coding guidelines. I am working on a similar
function in a subsequent PR. Landing this as NFC first to isolate this
change.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 6 +++---
 clang/lib/CodeGen/CodeGenModule.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e917f3c42da06..447204d6c23af 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2661,7 +2661,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const 
NamedDecl *ND) {
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   // Only if we are checking indirect calls.
   if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
@@ -3016,7 +3016,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 59f400570fb7a..1db5c3bc4e4ef 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1633,7 +1633,7 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Set type metadata to the given function.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/137874

>From 45778ad1a6cd0d7ce6333f6e8b69d4f4138b962e Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:43:32 -0700
Subject: [PATCH] [nfc][clang] Rename function

Rename function to meet the coding guidelines. I am working on a similar
function in a subsequent PR. Landing this as NFC first to isolate this
change.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 6 +++---
 clang/lib/CodeGen/CodeGenModule.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e917f3c42da06..447204d6c23af 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2661,7 +2661,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const 
NamedDecl *ND) {
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   // Only if we are checking indirect calls.
   if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
@@ -3016,7 +3016,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 59f400570fb7a..1db5c3bc4e4ef 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1633,7 +1633,7 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Set type metadata to the given function.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][clang] No sharedlibs for UEFI (PR #137872)

2025-05-01 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk closed 
https://github.com/llvm/llvm-project/pull/137872
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] UEFI default ABI (PR #138364)

2025-05-02 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk created 
https://github.com/llvm/llvm-project/pull/138364

Set MS ABI as default ABI for UEFI.


>From d0786948b07adb0318a19562c9a9ee72e893feef Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Fri, 2 May 2025 23:38:40 +
Subject: [PATCH] [clang] UEFI default ABI

Set MS ABI as default ABI for UEFI.
---
 clang/lib/Driver/ToolChains/Arch/X86.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index e6ac3a9e4b350..eea0c9e2ae6e0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -122,7 +122,7 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
   // "ms_abi" as default function attributes.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {
-StringRef DefaultAbi = Triple.isOSWindows() ? "ms" : "sysv";
+StringRef DefaultAbi = Triple.isOSWindowsOrUEFI() ? "ms" : "sysv";
 if (A->getValue() != DefaultAbi)
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << Triple.getTriple();

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits