llvm.org GIT mirror llvm / 8f637ad
Revert 172027 and 174336. Remove diagnostics about over-aligned stack objects. Aside from the question of whether we report a warning or an error when we can't satisfy a requested stack object alignment, the current implementation of this is not good. We're not providing any source location in the diagnostics and the current warning is not connected to any warning group so you can't control it. We could improve the source location somewhat, but we can do a much better job if this check is implemented in the front-end, so let's do that instead. <rdar://problem/13127907> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174741 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 7 years ago
6 changed file(s) with 27 addition(s) and 73 deletion(s). Raw diff Collapse all Expand all
492492 return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
493493 }
494494
495 /// CreateStackObjectWithMinAlign - Create a new statically sized stack
496 /// object, returning a nonnegative identifier to represent it. This function
497 /// takes a preferred alignment and a minimal alignment.
498 ///
499 int CreateStackObjectWithMinAlign(uint64_t Size, unsigned PrefAlignment,
500 unsigned MinAlignment, bool isSS,
495 /// CreateStackObject - Create a new statically sized stack object, returning
496 /// a nonnegative identifier to represent it.
497 ///
498 int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
501499 bool MayNeedSP = false, const AllocaInst *Alloca = 0);
502
503 /// CreateStackObject - Create a new statically sized stack object, returning
504 /// a nonnegative identifier to represent it. Will not emit an error when
505 /// Alignment can't be satisfied.
506 ///
507 int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
508 bool MayNeedSP = false, const AllocaInst *Alloca = 0) {
509 return CreateStackObjectWithMinAlign(Size, Alignment, 0, isSS,
510 MayNeedSP, Alloca);
511 }
512500
513501 /// CreateSpillStackObject - Create a new statically sized stack object that
514502 /// represents a spill slot, returning a nonnegative identifier to represent
528516 /// variable sized object is created, whether or not the index returned is
529517 /// actually used.
530518 ///
531 int CreateVariableSizedObject(unsigned PrefAlignment, unsigned MinAlignment,
532 const AllocaInst *Alloca = 0);
519 int CreateVariableSizedObject(unsigned Alignment);
533520
534521 /// getCalleeSavedInfo - Returns a reference to call saved info vector for the
535522 /// current function.
465465 }
466466
467467 /// clampStackAlignment - Clamp the alignment if requested and emit a warning.
468 static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned PrefAlign,
469 unsigned MinAlign, unsigned StackAlign,
470 const AllocaInst *Alloca = 0) {
471 if (!ShouldClamp || PrefAlign <= StackAlign)
472 return PrefAlign;
473 if (Alloca && MinAlign > StackAlign)
474 Alloca->getParent()->getContext().emitWarning(Alloca,
475 "Requested alignment exceeds the stack alignment!");
476 else
477 assert(MinAlign <= StackAlign &&
478 "Requested alignment exceeds the stack alignment!");
468 static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned Align,
469 unsigned StackAlign) {
470 if (!ShouldClamp || Align <= StackAlign)
471 return Align;
472 DEBUG(dbgs() << "Warning: requested alignment " << Align
473 << " exceeds the stack alignment " << StackAlign
474 << " when stack realignment is off" << '\n');
479475 return StackAlign;
480476 }
481477
482 /// CreateStackObjectWithMinAlign - Create a new statically sized stack
483 /// object, returning a nonnegative identifier to represent it. This function
484 /// takes a preferred alignment and a minimal alignment.
485 ///
486 int MachineFrameInfo::CreateStackObjectWithMinAlign(uint64_t Size,
487 unsigned PrefAlignment, unsigned MinAlignment,
488 bool isSS, bool MayNeedSP, const AllocaInst *Alloca) {
478 /// CreateStackObject - Create a new statically sized stack object, returning
479 /// a nonnegative identifier to represent it.
480 ///
481 int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment,
482 bool isSS, bool MayNeedSP, const AllocaInst *Alloca) {
489483 assert(Size != 0 && "Cannot allocate zero size stack objects!");
490 unsigned Alignment = clampStackAlignment(
491 !TFI.isStackRealignable() || !RealignOption,
492 PrefAlignment, MinAlignment,
493 TFI.getStackAlignment(), Alloca);
484 Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
485 Alignment, TFI.getStackAlignment());
494486 Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP,
495487 Alloca));
496488 int Index = (int)Objects.size() - NumFixedObjects - 1;
506498 int MachineFrameInfo::CreateSpillStackObject(uint64_t Size,
507499 unsigned Alignment) {
508500 Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
509 Alignment, 0,
510 TFI.getStackAlignment());
501 Alignment, TFI.getStackAlignment());
511502 CreateStackObject(Size, Alignment, true, false);
512503 int Index = (int)Objects.size() - NumFixedObjects - 1;
513504 ensureMaxAlignment(Alignment);
519510 /// variable sized object is created, whether or not the index returned is
520511 /// actually used.
521512 ///
522 int MachineFrameInfo::CreateVariableSizedObject(unsigned PrefAlignment,
523 unsigned MinAlignment, const AllocaInst *Alloca) {
513 int MachineFrameInfo::CreateVariableSizedObject(unsigned Alignment) {
524514 HasVarSizedObjects = true;
525 unsigned Alignment = clampStackAlignment(
526 !TFI.isStackRealignable() || !RealignOption,
527 PrefAlignment, MinAlignment,
528 TFI.getStackAlignment(), Alloca);
515 Alignment = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
516 Alignment, TFI.getStackAlignment());
529517 Objects.push_back(StackObject(0, Alignment, 0, false, false, true, 0));
530518 ensureMaxAlignment(Alignment);
531519 return (int)Objects.size()-NumFixedObjects-1;
546534 unsigned StackAlign = TFI.getStackAlignment();
547535 unsigned Align = MinAlign(SPOffset, StackAlign);
548536 Align = clampStackAlignment(!TFI.isStackRealignable() || !RealignOption,
549 Align, 0, TFI.getStackAlignment());
537 Align, TFI.getStackAlignment());
550538 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
551539 /*isSS*/ false,
552540 /*NeedSP*/ false,
9494 (TySize >= 8 && isa(Ty) &&
9595 cast(Ty)->getElementType()->isIntegerTy(8)));
9696 StaticAllocaMap[AI] =
97 MF->getFrameInfo()->CreateStackObjectWithMinAlign(TySize, Align,
98 AI->getAlignment(), false,
97 MF->getFrameInfo()->CreateStackObject(TySize, Align, false,
9998 MayNeedSP, AI);
10099 }
101100
32583258
32593259 // Inform the Frame Information that we have just allocated a variable-sized
32603260 // object.
3261 FuncInfo.MF->getFrameInfo()->CreateVariableSizedObject(Align ? Align : 1,
3262 I.getAlignment(), &I);
3261 FuncInfo.MF->getFrameInfo()->CreateVariableSizedObject(Align ? Align : 1);
32633262 }
32643263
32653264 void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
+0
-19
test/CodeGen/ARM/alloc-no-stack-realign-error.ll less more
None ; RUN: llc < %s -mtriple=armv7-apple-ios -O0 -realign-stack=0 2>&1 | FileCheck %s
1
2 ; rdar://12713765
3 @T3_retval = common global <16 x float> zeroinitializer, align 16
4
5 ; If alignment for alloc is smaller than or equal to stack alignment, but the
6 ; preferred type alignment is bigger, the alignment will be clamped.
7 ; If alignment for alloca is bigger than stack alignment, the compiler
8 ; will emit a warning.
9 define void @test(<16 x float>* noalias sret %agg.result) nounwind ssp {
10 entry:
11 ; CHECK: warning: Requested alignment exceeds the stack alignment!
12 %retval = alloca <16 x float>, align 16
13 %0 = load <16 x float>* @T3_retval, align 16
14 store <16 x float> %0, <16 x float>* %retval
15 %1 = load <16 x float>* %retval
16 store <16 x float> %1, <16 x float>* %agg.result, align 16
17 ret void
18 }
3838 ; NO-REALIGN: add [[R2:r[0-9]+]], [[R1:r[0-9]+]], #16
3939 ; NO-REALIGN: vst1.64
4040 ; NO-REALIGN: vst1.64
41 %retval = alloca <16 x float>, align 4
41 %retval = alloca <16 x float>, align 16
4242 %0 = load <16 x float>* @T3_retval, align 16
4343 store <16 x float> %0, <16 x float>* %retval
4444 %1 = load <16 x float>* %retval