[PATCH] D90544: [X86] NOT FOR COMMIT. Emit lifetime markers for MXCSR temporaries.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 31 20:51:50 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: andreadb, RKSimon, spatel.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
craig.topper requested review of this revision.

My experimental patch for PR48033 so I can share it in the bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90544

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -11895,16 +11895,28 @@
   case X86::BI_mm_setcsr:
   case X86::BI__builtin_ia32_ldmxcsr: {
     Address Tmp = CreateMemTemp(E->getArg(0)->getType());
+    llvm::Value *TmpPtr = Tmp.getPointer();
+    llvm::Value *TmpSize = EmitLifetimeStart(
+        CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
     Builder.CreateStore(Ops[0], Tmp);
-    return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr),
-                          Builder.CreateBitCast(Tmp.getPointer(), Int8PtrTy));
+    Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr),
+                                     Builder.CreateBitCast(Tmp.getPointer(), Int8PtrTy));
+    if (TmpSize)
+      EmitLifetimeEnd(TmpSize, TmpPtr);
+    return Call;
   }
   case X86::BI_mm_getcsr:
   case X86::BI__builtin_ia32_stmxcsr: {
     Address Tmp = CreateMemTemp(E->getType());
+    llvm::Value *TmpPtr = Tmp.getPointer();
+    llvm::Value *TmpSize = EmitLifetimeStart(
+        CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
     Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr),
                        Builder.CreateBitCast(Tmp.getPointer(), Int8PtrTy));
-    return Builder.CreateLoad(Tmp, "stmxcsr");
+    Value *Call = Builder.CreateLoad(Tmp, "stmxcsr");
+    if (TmpSize)
+      EmitLifetimeEnd(TmpSize, TmpPtr);
+    return Call;
   }
   case X86::BI__builtin_ia32_xsave:
   case X86::BI__builtin_ia32_xsave64:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90544.302117.patch
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201101/3f5cc880/attachment.bin>


More information about the llvm-commits mailing list