[clang] [clang][codegen] Don't mark "int" TBAA on FP libcalls with indirect args (PR #108853)

Benjamin Maxwell via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 01:00:43 PDT 2024


================
@@ -686,12 +686,31 @@ static Value *EmitSignBit(CodeGenFunction &CGF, Value *V) {
   return CGF.Builder.CreateICmpSLT(V, Zero);
 }
 
+/// Checks no arguments or results are passed indirectly in the ABI (i.e. via a
+/// hidden pointer). This is used to check annotating FP libcalls (that could
+/// set `errno`) with "int" TBAA metadata is safe. If any floating-point
+/// arguments are passed indirectly, setup for the call could be incorrectly
+/// optimized out.
+static bool HasNoIndirectArgumentsOrResults(CGFunctionInfo const &FnInfo) {
+  auto IsIndirect = [&](ABIArgInfo const &info) {
----------------
MacDue wrote:

If you mean on the clang function declaration, they're not a pointer there (it's just how the ABI says to pass them).

If you mean why not check the LLVM function declaration, one reason is the pointers are opaque/untyped there, which may prevent setting the metadata on functions like `float frexpf(float, int*)` (which is a TODO in one of the tests).

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


More information about the cfe-commits mailing list