[PATCH] D32570: Assert that getMaxCallFrameSize() is computed before it is queried
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 16:25:47 PDT 2017
MatzeB created this revision.
Herald added subscribers: mcrosier, rengolin, aemerson.
Assert that we do not query MaxCallFrameSize before it is computed. I stumbled unto this while investigating an ARM bug.
However adding this assert is hit in various places (from the 4 targets I tested ARM, AArch64 and PowerPC failed tests and only X86 was clean). Putting this here for discussion/reference for now as we obviously need more fixes before applying it.
Repository:
rL LLVM
https://reviews.llvm.org/D32570
Files:
include/llvm/CodeGen/MIRYamlMapping.h
include/llvm/CodeGen/MachineFrameInfo.h
lib/CodeGen/MIRParser/MIRParser.cpp
lib/CodeGen/MIRPrinter.cpp
Index: lib/CodeGen/MIRPrinter.cpp
===================================================================
--- lib/CodeGen/MIRPrinter.cpp
+++ lib/CodeGen/MIRPrinter.cpp
@@ -286,7 +286,9 @@
YamlMFI.MaxAlignment = MFI.getMaxAlignment();
YamlMFI.AdjustsStack = MFI.adjustsStack();
YamlMFI.HasCalls = MFI.hasCalls();
- YamlMFI.MaxCallFrameSize = MFI.getMaxCallFrameSize();
+ YamlMFI.MaxCallFrameSizeComputed = MFI.isMaxCallFrameSizeComputed();
+ YamlMFI.MaxCallFrameSize = MFI.isMaxCallFrameSizeComputed()
+ ? MFI.getMaxCallFrameSize() : 0;
YamlMFI.HasOpaqueSPAdjustment = MFI.hasOpaqueSPAdjustment();
YamlMFI.HasVAStart = MFI.hasVAStart();
YamlMFI.HasMustTailInVarArgFunc = MFI.hasMustTailInVarArgFunc();
Index: lib/CodeGen/MIRParser/MIRParser.cpp
===================================================================
--- lib/CodeGen/MIRParser/MIRParser.cpp
+++ lib/CodeGen/MIRParser/MIRParser.cpp
@@ -541,7 +541,8 @@
MFI.ensureMaxAlignment(YamlMFI.MaxAlignment);
MFI.setAdjustsStack(YamlMFI.AdjustsStack);
MFI.setHasCalls(YamlMFI.HasCalls);
- MFI.setMaxCallFrameSize(YamlMFI.MaxCallFrameSize);
+ if (YamlMFI.isMaxCallFrameSizeComputed)
+ MFI.setMaxCallFrameSize(YamlMFI.MaxCallFrameSize);
MFI.setHasOpaqueSPAdjustment(YamlMFI.HasOpaqueSPAdjustment);
MFI.setHasVAStart(YamlMFI.HasVAStart);
MFI.setHasMustTailInVarArgFunc(YamlMFI.HasMustTailInVarArgFunc);
Index: include/llvm/CodeGen/MachineFrameInfo.h
===================================================================
--- include/llvm/CodeGen/MachineFrameInfo.h
+++ include/llvm/CodeGen/MachineFrameInfo.h
@@ -220,7 +220,7 @@
/// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
/// class). This information is important for frame pointer elimination.
/// It is only valid during and after prolog/epilog code insertion.
- unsigned MaxCallFrameSize = 0;
+ unsigned MaxCallFrameSize = ~0u;
/// The prolog/epilog code inserter fills in this vector with each
/// callee saved register saved in the frame. Beyond its use by the prolog/
@@ -525,7 +525,13 @@
/// CallFrameSetup/Destroy pseudo instructions are used by the target, and
/// then only during or after prolog/epilog code insertion.
///
- unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
+ unsigned getMaxCallFrameSize() const {
+ assert(isMaxCallFrameSizeComputed() && "MaxCallFrameSize not computed yet");
+ return MaxCallFrameSize;
+ }
+ bool isMaxCallFrameSizeComputed() const {
+ return MaxCallFrameSize != ~0u;
+ }
void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
/// Create a new object at a fixed location on the stack.
Index: include/llvm/CodeGen/MIRYamlMapping.h
===================================================================
--- include/llvm/CodeGen/MIRYamlMapping.h
+++ include/llvm/CodeGen/MIRYamlMapping.h
@@ -345,6 +345,7 @@
bool HasCalls = false;
StringValue StackProtector;
// TODO: Serialize FunctionContextIdx
+ bool MaxCallFrameSizeComputed = false;
unsigned MaxCallFrameSize = 0;
bool HasOpaqueSPAdjustment = false;
bool HasVAStart = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32570.96846.patch
Type: text/x-patch
Size: 3134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170426/98671d5b/attachment.bin>
More information about the llvm-commits
mailing list