[clang] f710612 - Revert "[clang][codegen] Fix possible crash when setting TBAA metadata on FP math libcalls (#108575)"

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 03:51:33 PDT 2024


Author: Martin Storsjö
Date: 2024-09-16T13:51:16+03:00
New Revision: f71061258484390cb74752e9d7e486264aa4db0a

URL: https://github.com/llvm/llvm-project/commit/f71061258484390cb74752e9d7e486264aa4db0a
DIFF: https://github.com/llvm/llvm-project/commit/f71061258484390cb74752e9d7e486264aa4db0a.diff

LOG: Revert "[clang][codegen] Fix possible crash when setting TBAA metadata on FP math libcalls (#108575)"

This reverts commit a56ca1a0fb248c6f38b5841323a74673748f43ea.

This commit broke code generation for x86 mingw targets, with regards
to long double math functions - see
https://github.com/llvm/llvm-project/pull/108575#issuecomment-2352574978
for details.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a76cd5f9a6f47d..a52e880a764252 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -690,10 +690,8 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD,
                               const CallExpr *E, llvm::Constant *calleeValue) {
   CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
   CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD));
-  llvm::CallBase *callOrInvoke = nullptr;
   RValue Call =
-      CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot(),
-                   /*Chain=*/nullptr, &callOrInvoke);
+      CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
   if (unsigned BuiltinID = FD->getBuiltinID()) {
     // Check whether a FP math builtin function, such as BI__builtin_expf
@@ -707,7 +705,8 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD,
       // Emit "int" TBAA metadata on FP math libcalls.
       clang::QualType IntTy = Context.IntTy;
       TBAAAccessInfo TBAAInfo = CGF.CGM.getTBAAAccessInfo(IntTy);
-      CGF.CGM.DecorateInstructionWithTBAA(callOrInvoke, TBAAInfo);
+      Instruction *Inst = cast<llvm::Instruction>(Call.getScalarVal());
+      CGF.CGM.DecorateInstructionWithTBAA(Inst, TBAAInfo);
     }
   }
   return Call;


        


More information about the cfe-commits mailing list