mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 20:59:51 +00:00
Add support alignment of allocation instructions.
Add support for specifying alignment and size of setjmp jmpbufs. No targets currently do anything with this information, nor is it presrved in the bytecode representation. That's coming up next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ae4664a9f2
commit
14b0529532
@ -33,10 +33,11 @@ class PointerType;
|
||||
/// AllocaInst.
|
||||
///
|
||||
class AllocationInst : public UnaryInstruction {
|
||||
unsigned Alignment;
|
||||
protected:
|
||||
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
|
||||
const std::string &Name = "", Instruction *InsertBefore = 0);
|
||||
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
|
||||
const std::string &Name, BasicBlock *InsertAtEnd);
|
||||
|
||||
public:
|
||||
@ -63,6 +64,11 @@ public:
|
||||
///
|
||||
const Type *getAllocatedType() const;
|
||||
|
||||
/// getAlignment - Return the alignment of the memory that is being allocated
|
||||
/// by the instruction.
|
||||
///
|
||||
unsigned getAlignment() const { return Alignment; }
|
||||
|
||||
virtual Instruction *clone() const = 0;
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
@ -89,11 +95,18 @@ public:
|
||||
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
|
||||
const std::string &Name = "",
|
||||
Instruction *InsertBefore = 0)
|
||||
: AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {}
|
||||
: AllocationInst(Ty, ArraySize, Malloc, 0, Name, InsertBefore) {}
|
||||
MallocInst(const Type *Ty, Value *ArraySize, const std::string &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: AllocationInst(Ty, ArraySize, Malloc, Name, InsertAtEnd) {}
|
||||
|
||||
: AllocationInst(Ty, ArraySize, Malloc, 0, Name, InsertAtEnd) {}
|
||||
MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
|
||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||
: AllocationInst(Ty, ArraySize, Malloc, Align, Name, InsertAtEnd) {}
|
||||
explicit MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
|
||||
const std::string &Name = "",
|
||||
Instruction *InsertBefore = 0)
|
||||
: AllocationInst(Ty, ArraySize, Malloc, Align, Name, InsertBefore) {}
|
||||
|
||||
virtual MallocInst *clone() const;
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
@ -119,11 +132,18 @@ public:
|
||||
explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
|
||||
const std::string &Name = "",
|
||||
Instruction *InsertBefore = 0)
|
||||
: AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {}
|
||||
: AllocationInst(Ty, ArraySize, Alloca, 0, Name, InsertBefore) {}
|
||||
AllocaInst(const Type *Ty, Value *ArraySize, const std::string &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: AllocationInst(Ty, ArraySize, Alloca, Name, InsertAtEnd) {}
|
||||
|
||||
: AllocationInst(Ty, ArraySize, Alloca, 0, Name, InsertAtEnd) {}
|
||||
AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
|
||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||
: AllocationInst(Ty, ArraySize, Alloca, Align, Name, InsertAtEnd) {}
|
||||
explicit AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
|
||||
const std::string &Name = "",
|
||||
Instruction *InsertBefore = 0)
|
||||
: AllocationInst(Ty, ArraySize, Alloca, Align, Name, InsertBefore) {}
|
||||
|
||||
virtual AllocaInst *clone() const;
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
|
@ -271,7 +271,8 @@ FunctionPass *createLowerPackedPass();
|
||||
// "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" lowering
|
||||
// pass.
|
||||
//
|
||||
FunctionPass *createLowerInvokePass();
|
||||
FunctionPass *createLowerInvokePass(unsigned JumBufSize = 200,
|
||||
unsigned JumpBufAlign = 0);
|
||||
extern const PassInfo *LowerInvokePassID;
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -231,6 +231,7 @@ double { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; }
|
||||
label { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; }
|
||||
type { return TYPE; }
|
||||
opaque { return OPAQUE; }
|
||||
align { return ALIGN; }
|
||||
|
||||
add { RET_TOK(BinaryOpVal, Add, ADD); }
|
||||
sub { RET_TOK(BinaryOpVal, Sub, SUB); }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,225 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 1.875d. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
ESINT64VAL = 258,
|
||||
EUINT64VAL = 259,
|
||||
SINTVAL = 260,
|
||||
UINTVAL = 261,
|
||||
FPVAL = 262,
|
||||
VOID = 263,
|
||||
BOOL = 264,
|
||||
SBYTE = 265,
|
||||
UBYTE = 266,
|
||||
SHORT = 267,
|
||||
USHORT = 268,
|
||||
INT = 269,
|
||||
UINT = 270,
|
||||
LONG = 271,
|
||||
ULONG = 272,
|
||||
FLOAT = 273,
|
||||
DOUBLE = 274,
|
||||
TYPE = 275,
|
||||
LABEL = 276,
|
||||
VAR_ID = 277,
|
||||
LABELSTR = 278,
|
||||
STRINGCONSTANT = 279,
|
||||
IMPLEMENTATION = 280,
|
||||
ZEROINITIALIZER = 281,
|
||||
TRUETOK = 282,
|
||||
FALSETOK = 283,
|
||||
BEGINTOK = 284,
|
||||
ENDTOK = 285,
|
||||
DECLARE = 286,
|
||||
GLOBAL = 287,
|
||||
CONSTANT = 288,
|
||||
VOLATILE = 289,
|
||||
TO = 290,
|
||||
DOTDOTDOT = 291,
|
||||
NULL_TOK = 292,
|
||||
UNDEF = 293,
|
||||
CONST = 294,
|
||||
INTERNAL = 295,
|
||||
LINKONCE = 296,
|
||||
WEAK = 297,
|
||||
APPENDING = 298,
|
||||
OPAQUE = 299,
|
||||
NOT = 300,
|
||||
EXTERNAL = 301,
|
||||
TARGET = 302,
|
||||
TRIPLE = 303,
|
||||
ENDIAN = 304,
|
||||
POINTERSIZE = 305,
|
||||
LITTLE = 306,
|
||||
BIG = 307,
|
||||
DEPLIBS = 308,
|
||||
CALL = 309,
|
||||
TAIL = 310,
|
||||
CC_TOK = 311,
|
||||
CCC_TOK = 312,
|
||||
FASTCC_TOK = 313,
|
||||
COLDCC_TOK = 314,
|
||||
RET = 315,
|
||||
BR = 316,
|
||||
SWITCH = 317,
|
||||
INVOKE = 318,
|
||||
UNWIND = 319,
|
||||
UNREACHABLE = 320,
|
||||
ADD = 321,
|
||||
SUB = 322,
|
||||
MUL = 323,
|
||||
DIV = 324,
|
||||
REM = 325,
|
||||
AND = 326,
|
||||
OR = 327,
|
||||
XOR = 328,
|
||||
SETLE = 329,
|
||||
SETGE = 330,
|
||||
SETLT = 331,
|
||||
SETGT = 332,
|
||||
SETEQ = 333,
|
||||
SETNE = 334,
|
||||
MALLOC = 335,
|
||||
ALLOCA = 336,
|
||||
FREE = 337,
|
||||
LOAD = 338,
|
||||
STORE = 339,
|
||||
GETELEMENTPTR = 340,
|
||||
PHI_TOK = 341,
|
||||
CAST = 342,
|
||||
SELECT = 343,
|
||||
SHL = 344,
|
||||
SHR = 345,
|
||||
VAARG = 346,
|
||||
VAARG_old = 347,
|
||||
VANEXT_old = 348
|
||||
};
|
||||
#endif
|
||||
#define ESINT64VAL 258
|
||||
#define EUINT64VAL 259
|
||||
#define SINTVAL 260
|
||||
#define UINTVAL 261
|
||||
#define FPVAL 262
|
||||
#define VOID 263
|
||||
#define BOOL 264
|
||||
#define SBYTE 265
|
||||
#define UBYTE 266
|
||||
#define SHORT 267
|
||||
#define USHORT 268
|
||||
#define INT 269
|
||||
#define UINT 270
|
||||
#define LONG 271
|
||||
#define ULONG 272
|
||||
#define FLOAT 273
|
||||
#define DOUBLE 274
|
||||
#define TYPE 275
|
||||
#define LABEL 276
|
||||
#define VAR_ID 277
|
||||
#define LABELSTR 278
|
||||
#define STRINGCONSTANT 279
|
||||
#define IMPLEMENTATION 280
|
||||
#define ZEROINITIALIZER 281
|
||||
#define TRUETOK 282
|
||||
#define FALSETOK 283
|
||||
#define BEGINTOK 284
|
||||
#define ENDTOK 285
|
||||
#define DECLARE 286
|
||||
#define GLOBAL 287
|
||||
#define CONSTANT 288
|
||||
#define VOLATILE 289
|
||||
#define TO 290
|
||||
#define DOTDOTDOT 291
|
||||
#define NULL_TOK 292
|
||||
#define UNDEF 293
|
||||
#define CONST 294
|
||||
#define INTERNAL 295
|
||||
#define LINKONCE 296
|
||||
#define WEAK 297
|
||||
#define APPENDING 298
|
||||
#define OPAQUE 299
|
||||
#define NOT 300
|
||||
#define EXTERNAL 301
|
||||
#define TARGET 302
|
||||
#define TRIPLE 303
|
||||
#define ENDIAN 304
|
||||
#define POINTERSIZE 305
|
||||
#define LITTLE 306
|
||||
#define BIG 307
|
||||
#define DEPLIBS 308
|
||||
#define CALL 309
|
||||
#define TAIL 310
|
||||
#define CC_TOK 311
|
||||
#define CCC_TOK 312
|
||||
#define FASTCC_TOK 313
|
||||
#define COLDCC_TOK 314
|
||||
#define RET 315
|
||||
#define BR 316
|
||||
#define SWITCH 317
|
||||
#define INVOKE 318
|
||||
#define UNWIND 319
|
||||
#define UNREACHABLE 320
|
||||
#define ADD 321
|
||||
#define SUB 322
|
||||
#define MUL 323
|
||||
#define DIV 324
|
||||
#define REM 325
|
||||
#define AND 326
|
||||
#define OR 327
|
||||
#define XOR 328
|
||||
#define SETLE 329
|
||||
#define SETGE 330
|
||||
#define SETLT 331
|
||||
#define SETGT 332
|
||||
#define SETEQ 333
|
||||
#define SETNE 334
|
||||
#define MALLOC 335
|
||||
#define ALLOCA 336
|
||||
#define FREE 337
|
||||
#define LOAD 338
|
||||
#define STORE 339
|
||||
#define GETELEMENTPTR 340
|
||||
#define PHI_TOK 341
|
||||
#define CAST 342
|
||||
#define SELECT 343
|
||||
#define SHL 344
|
||||
#define SHR 345
|
||||
#define VAARG 346
|
||||
#define VAARG_old 347
|
||||
#define VANEXT_old 348
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
#line 866 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
|
||||
typedef union YYSTYPE {
|
||||
typedef union {
|
||||
llvm::Module *ModuleVal;
|
||||
llvm::Function *FunctionVal;
|
||||
std::pair<llvm::PATypeHolder*, char*> *ArgVal;
|
||||
@ -258,14 +37,98 @@ typedef union YYSTYPE {
|
||||
llvm::Instruction::OtherOps OtherOpVal;
|
||||
llvm::Module::Endianness Endianness;
|
||||
} YYSTYPE;
|
||||
/* Line 1285 of yacc.c. */
|
||||
#line 263 "llvmAsmParser.tab.h"
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
#define ESINT64VAL 257
|
||||
#define EUINT64VAL 258
|
||||
#define SINTVAL 259
|
||||
#define UINTVAL 260
|
||||
#define FPVAL 261
|
||||
#define VOID 262
|
||||
#define BOOL 263
|
||||
#define SBYTE 264
|
||||
#define UBYTE 265
|
||||
#define SHORT 266
|
||||
#define USHORT 267
|
||||
#define INT 268
|
||||
#define UINT 269
|
||||
#define LONG 270
|
||||
#define ULONG 271
|
||||
#define FLOAT 272
|
||||
#define DOUBLE 273
|
||||
#define TYPE 274
|
||||
#define LABEL 275
|
||||
#define VAR_ID 276
|
||||
#define LABELSTR 277
|
||||
#define STRINGCONSTANT 278
|
||||
#define IMPLEMENTATION 279
|
||||
#define ZEROINITIALIZER 280
|
||||
#define TRUETOK 281
|
||||
#define FALSETOK 282
|
||||
#define BEGINTOK 283
|
||||
#define ENDTOK 284
|
||||
#define DECLARE 285
|
||||
#define GLOBAL 286
|
||||
#define CONSTANT 287
|
||||
#define VOLATILE 288
|
||||
#define TO 289
|
||||
#define DOTDOTDOT 290
|
||||
#define NULL_TOK 291
|
||||
#define UNDEF 292
|
||||
#define CONST 293
|
||||
#define INTERNAL 294
|
||||
#define LINKONCE 295
|
||||
#define WEAK 296
|
||||
#define APPENDING 297
|
||||
#define OPAQUE 298
|
||||
#define NOT 299
|
||||
#define EXTERNAL 300
|
||||
#define TARGET 301
|
||||
#define TRIPLE 302
|
||||
#define ENDIAN 303
|
||||
#define POINTERSIZE 304
|
||||
#define LITTLE 305
|
||||
#define BIG 306
|
||||
#define ALIGN 307
|
||||
#define DEPLIBS 308
|
||||
#define CALL 309
|
||||
#define TAIL 310
|
||||
#define CC_TOK 311
|
||||
#define CCC_TOK 312
|
||||
#define FASTCC_TOK 313
|
||||
#define COLDCC_TOK 314
|
||||
#define RET 315
|
||||
#define BR 316
|
||||
#define SWITCH 317
|
||||
#define INVOKE 318
|
||||
#define UNWIND 319
|
||||
#define UNREACHABLE 320
|
||||
#define ADD 321
|
||||
#define SUB 322
|
||||
#define MUL 323
|
||||
#define DIV 324
|
||||
#define REM 325
|
||||
#define AND 326
|
||||
#define OR 327
|
||||
#define XOR 328
|
||||
#define SETLE 329
|
||||
#define SETGE 330
|
||||
#define SETLT 331
|
||||
#define SETGT 332
|
||||
#define SETEQ 333
|
||||
#define SETNE 334
|
||||
#define MALLOC 335
|
||||
#define ALLOCA 336
|
||||
#define FREE 337
|
||||
#define LOAD 338
|
||||
#define STORE 339
|
||||
#define GETELEMENTPTR 340
|
||||
#define PHI_TOK 341
|
||||
#define CAST 342
|
||||
#define SELECT 343
|
||||
#define SHL 344
|
||||
#define SHR 345
|
||||
#define VAARG 346
|
||||
#define VAARG_old 347
|
||||
#define VANEXT_old 348
|
||||
|
||||
|
||||
extern YYSTYPE llvmAsmlval;
|
||||
|
||||
|
||||
|
||||
|
@ -953,7 +953,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
|
||||
%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
|
||||
%token DECLARE GLOBAL CONSTANT VOLATILE
|
||||
%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
|
||||
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
||||
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
|
||||
%token DEPLIBS CALL TAIL
|
||||
%token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK
|
||||
%type <UIntVal> OptCallingConv
|
||||
@ -2208,18 +2208,34 @@ MemoryInst : MALLOC Types {
|
||||
$$ = new MallocInst(*$2);
|
||||
delete $2;
|
||||
}
|
||||
| MALLOC Types ',' ALIGN EUINT64VAL {
|
||||
$$ = new MallocInst(*$2, 0, $5);
|
||||
delete $2;
|
||||
}
|
||||
| MALLOC Types ',' UINT ValueRef {
|
||||
$$ = new MallocInst(*$2, getVal($4, $5));
|
||||
delete $2;
|
||||
}
|
||||
| MALLOC Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
|
||||
$$ = new MallocInst(*$2, getVal($4, $5), $8);
|
||||
delete $2;
|
||||
}
|
||||
| ALLOCA Types {
|
||||
$$ = new AllocaInst(*$2);
|
||||
delete $2;
|
||||
}
|
||||
| ALLOCA Types ',' ALIGN EUINT64VAL {
|
||||
$$ = new AllocaInst(*$2, 0, $5);
|
||||
delete $2;
|
||||
}
|
||||
| ALLOCA Types ',' UINT ValueRef {
|
||||
$$ = new AllocaInst(*$2, getVal($4, $5));
|
||||
delete $2;
|
||||
}
|
||||
| ALLOCA Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
|
||||
$$ = new AllocaInst(*$2, getVal($4, $5), $8);
|
||||
delete $2;
|
||||
}
|
||||
| FREE ResolvedVal {
|
||||
if (!isa<PointerType>($2->getType()))
|
||||
ThrowException("Trying to free nonpointer type " +
|
||||
|
@ -678,7 +678,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
|
||||
(unsigned)NElements->getRawValue());
|
||||
MallocInst *NewMI =
|
||||
new MallocInst(NewTy, Constant::getNullValue(Type::UIntTy),
|
||||
MI->getName(), MI);
|
||||
MI->getAlignment(), MI->getName(), MI);
|
||||
std::vector<Value*> Indices;
|
||||
Indices.push_back(Constant::getNullValue(Type::IntTy));
|
||||
Indices.push_back(Indices[0]);
|
||||
@ -950,6 +950,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
|
||||
DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV);
|
||||
Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin();
|
||||
const Type* ElemTy = GV->getType()->getElementType();
|
||||
// FIXME: Pass Global's alignment when globals have alignment
|
||||
AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI);
|
||||
if (!isa<UndefValue>(GV->getInitializer()))
|
||||
new StoreInst(GV->getInitializer(), Alloca, FirstI);
|
||||
|
@ -3936,9 +3936,9 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
|
||||
std::string Name = AI.getName(); AI.setName("");
|
||||
AllocationInst *New;
|
||||
if (isa<MallocInst>(AI))
|
||||
New = new MallocInst(CastElTy, Amt, Name);
|
||||
New = new MallocInst(CastElTy, Amt, AI.getAlignment(), Name);
|
||||
else
|
||||
New = new AllocaInst(CastElTy, Amt, Name);
|
||||
New = new AllocaInst(CastElTy, Amt, AI.getAlignment(), Name);
|
||||
InsertNewInstBefore(New, AI);
|
||||
|
||||
// If the allocation has multiple uses, insert a cast and change all things
|
||||
@ -5266,10 +5266,10 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
|
||||
|
||||
// Create and insert the replacement instruction...
|
||||
if (isa<MallocInst>(AI))
|
||||
New = new MallocInst(NewTy, 0, AI.getName());
|
||||
New = new MallocInst(NewTy, 0, AI.getAlignment(), AI.getName());
|
||||
else {
|
||||
assert(isa<AllocaInst>(AI) && "Unknown type of allocation inst!");
|
||||
New = new AllocaInst(NewTy, 0, AI.getName());
|
||||
New = new AllocaInst(NewTy, 0, AI.getAlignment(), AI.getName());
|
||||
}
|
||||
|
||||
InsertNewInstBefore(New, AI);
|
||||
|
@ -159,7 +159,8 @@ bool SROA::performScalarRepl(Function &F) {
|
||||
if (const StructType *ST = dyn_cast<StructType>(AI->getAllocatedType())) {
|
||||
ElementAllocas.reserve(ST->getNumContainedTypes());
|
||||
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
|
||||
AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
|
||||
AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
|
||||
AI->getAlignment(),
|
||||
AI->getName() + "." + utostr(i), AI);
|
||||
ElementAllocas.push_back(NA);
|
||||
WorkList.push_back(NA); // Add to worklist for recursive processing
|
||||
@ -169,7 +170,7 @@ bool SROA::performScalarRepl(Function &F) {
|
||||
ElementAllocas.reserve(AT->getNumElements());
|
||||
const Type *ElTy = AT->getElementType();
|
||||
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
|
||||
AllocaInst *NA = new AllocaInst(ElTy, 0,
|
||||
AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
|
||||
AI->getName() + "." + utostr(i), AI);
|
||||
ElementAllocas.push_back(NA);
|
||||
WorkList.push_back(NA); // Add to worklist for recursive processing
|
||||
|
@ -67,6 +67,8 @@ namespace {
|
||||
GlobalVariable *JBListHead;
|
||||
Function *SetJmpFn, *LongJmpFn;
|
||||
public:
|
||||
LowerInvoke(unsigned Size = 200, unsigned Align = 0) : JumpBufSize(Size),
|
||||
JumpBufAlign(Align) {}
|
||||
bool doInitialization(Module &M);
|
||||
bool runOnFunction(Function &F);
|
||||
|
||||
@ -78,6 +80,9 @@ namespace {
|
||||
void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
|
||||
AllocaInst *InvokeNum, SwitchInst *CatchSwitch);
|
||||
bool insertExpensiveEHSupport(Function &F);
|
||||
|
||||
unsigned JumpBufSize;
|
||||
unsigned JumpBufAlign;
|
||||
};
|
||||
|
||||
RegisterOpt<LowerInvoke>
|
||||
@ -87,7 +92,10 @@ namespace {
|
||||
const PassInfo *llvm::LowerInvokePassID = X.getPassInfo();
|
||||
|
||||
// Public Interface To the LowerInvoke pass.
|
||||
FunctionPass *llvm::createLowerInvokePass() { return new LowerInvoke(); }
|
||||
FunctionPass *llvm::createLowerInvokePass(unsigned JumpBufSize,
|
||||
unsigned JumpBufAlign) {
|
||||
return new LowerInvoke(JumpBufSize, JumpBufAlign);
|
||||
}
|
||||
|
||||
// doInitialization - Make sure that there is a prototype for abort in the
|
||||
// current module.
|
||||
@ -95,13 +103,8 @@ bool LowerInvoke::doInitialization(Module &M) {
|
||||
const Type *VoidPtrTy = PointerType::get(Type::SByteTy);
|
||||
AbortMessage = 0;
|
||||
if (ExpensiveEHSupport) {
|
||||
// Insert a type for the linked list of jump buffers. Unfortunately, we
|
||||
// don't know the size of the target's setjmp buffer, so we make a guess.
|
||||
// If this guess turns out to be too small, bad stuff could happen.
|
||||
unsigned JmpBufSize = 200; // PPC has 192 words
|
||||
assert(sizeof(jmp_buf) <= JmpBufSize*sizeof(void*) &&
|
||||
"LowerInvoke doesn't know about targets with jmp_buf size > 200 words!");
|
||||
const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JmpBufSize);
|
||||
// Insert a type for the linked list of jump buffers.
|
||||
const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JumpBufSize);
|
||||
|
||||
{ // The type is recursive, so use a type holder.
|
||||
std::vector<const Type*> Elements;
|
||||
@ -441,7 +444,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
// that needs to be restored on all exits from the function. This is an
|
||||
// alloca because the value needs to be live across invokes.
|
||||
AllocaInst *JmpBuf =
|
||||
new AllocaInst(JBLinkTy, 0, "jblink", F.begin()->begin());
|
||||
new AllocaInst(JBLinkTy, 0, JumpBufAlign, "jblink", F.begin()->begin());
|
||||
|
||||
std::vector<Value*> Idx;
|
||||
Idx.push_back(Constant::getNullValue(Type::IntTy));
|
||||
|
@ -1172,6 +1172,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
||||
Out << ',';
|
||||
writeOperand(AI->getArraySize(), true);
|
||||
}
|
||||
if (AI->getAlignment()) {
|
||||
Out << ", " << AI->getAlignment();
|
||||
}
|
||||
} else if (isa<CastInst>(I)) {
|
||||
if (Operand) writeOperand(Operand, true); // Work with broken code
|
||||
Out << " to ";
|
||||
|
@ -494,18 +494,18 @@ static Value *getAISize(Value *Amt) {
|
||||
}
|
||||
|
||||
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||
const std::string &Name,
|
||||
unsigned Align, const std::string &Name,
|
||||
Instruction *InsertBefore)
|
||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||
Name, InsertBefore) {
|
||||
Name, InsertBefore), Alignment(Align) {
|
||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||
}
|
||||
|
||||
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||
const std::string &Name,
|
||||
unsigned Align, const std::string &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||
Name, InsertAtEnd) {
|
||||
Name, InsertAtEnd), Alignment(Align) {
|
||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||
}
|
||||
|
||||
@ -521,12 +521,12 @@ const Type *AllocationInst::getAllocatedType() const {
|
||||
|
||||
AllocaInst::AllocaInst(const AllocaInst &AI)
|
||||
: AllocationInst(AI.getType()->getElementType(), (Value*)AI.getOperand(0),
|
||||
Instruction::Alloca) {
|
||||
Instruction::Alloca, AI.getAlignment()) {
|
||||
}
|
||||
|
||||
MallocInst::MallocInst(const MallocInst &MI)
|
||||
: AllocationInst(MI.getType()->getElementType(), (Value*)MI.getOperand(0),
|
||||
Instruction::Malloc) {
|
||||
Instruction::Malloc, MI.getAlignment()) {
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Loading…
Reference in New Issue
Block a user