[PATCH] D11009: Redirect DataLayout from TargetMachine to Module in SjLjEHPrepare

Mehdi AMINI mehdi.amini at apple.com
Tue Jul 7 12:48:30 PDT 2015


joker.eph added a reviewer: echristo.
joker.eph added subscribers: llvm-commits, rafael, yaron.keren.

This change is part of a series of commits dedicated to have a single
DataLayout during compilation by using always the one owned by the
module.

http://reviews.llvm.org/D11009

Files:
  lib/CodeGen/SjLjEHPrepare.cpp

Index: lib/CodeGen/SjLjEHPrepare.cpp
===================================================================
--- lib/CodeGen/SjLjEHPrepare.cpp
+++ lib/CodeGen/SjLjEHPrepare.cpp
@@ -45,7 +45,6 @@
 
 namespace {
 class SjLjEHPrepare : public FunctionPass {
-  const TargetMachine *TM;
   Type *doubleUnderDataTy;
   Type *doubleUnderJBufTy;
   Type *FunctionContextTy;
@@ -63,7 +62,7 @@
 
 public:
   static char ID; // Pass identification, replacement for typeid
-  explicit SjLjEHPrepare(const TargetMachine *TM) : FunctionPass(ID), TM(TM) {}
+  explicit SjLjEHPrepare(const TargetMachine *TM) : FunctionPass(ID) {}
   bool doInitialization(Module &M) override;
   bool runOnFunction(Function &F) override;
 
@@ -196,9 +195,8 @@
   // Create an alloca for the incoming jump buffer ptr and the new jump buffer
   // that needs to be restored on all exits from the function. This is an alloca
   // because the value needs to be added to the global context list.
-  const TargetLowering *TLI = TM->getSubtargetImpl(F)->getTargetLowering();
-  unsigned Align =
-      TLI->getDataLayout()->getPrefTypeAlignment(FunctionContextTy);
+  auto &DL = F.getParent()->getDataLayout();
+  unsigned Align = DL.getPrefTypeAlignment(FunctionContextTy);
   FuncCtx = new AllocaInst(FunctionContextTy, nullptr, Align, "fn_context",
                            EntryBB->begin());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11009.29202.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150707/67e329a6/attachment.bin>


More information about the llvm-commits mailing list