diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-04-02 21:44:55 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-04-02 21:44:55 +0000 |
commit | 92b9c6e6fe060df555c532d1f4d18fc14ba5e1a6 (patch) | |
tree | 6d8d346ac7fcedbf0cb27abd60bb7f8b024d18a2 /llvm/lib/Transforms | |
parent | 7fab90f0e82581f70923af8a266fe585a8d9a67b (diff) | |
download | bcm5719-llvm-92b9c6e6fe060df555c532d1f4d18fc14ba5e1a6.tar.gz bcm5719-llvm-92b9c6e6fe060df555c532d1f4d18fc14ba5e1a6.zip |
[ASan] Don't use stack malloc for 32-bit functions using inline asm
This prevents us from running out of registers in the backend.
Introducing stack malloc calls prevents the backend from recognizing the
inline asm operands as stack objects. When the backend recognizes a
stack object, it doesn't need to materialize the address of the memory
in a physical register. Instead it generates a simple SP-based memory
operand. Introducing a stack malloc forces the backend to find a free
register for every memory operand. 32-bit x86 simply doesn't have enough
registers for this to succeed in most cases.
Reviewers: kcc, samsonov
Differential Revision: http://reviews.llvm.org/D8790
llvm-svn: 233979
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index e483d6f9e3b..9ccb82b759f 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1766,9 +1766,11 @@ void FunctionStackPoisoner::poisonStack() { uint64_t LocalStackSize = L.FrameSize; bool DoStackMalloc = ClUseAfterReturn && LocalStackSize <= kMaxStackMallocSize; - // Don't do dynamic alloca in presence of inline asm: too often it - // makes assumptions on which registers are available. + // Don't do dynamic alloca in presence of inline asm: too often it makes + // assumptions on which registers are available. Don't do stack malloc in the + // presence of inline asm on 32-bit platforms for the same reason. bool DoDynamicAlloca = ClDynamicAllocaStack && !HasNonEmptyInlineAsm; + DoStackMalloc &= !HasNonEmptyInlineAsm || ASan.LongSize != 32; Value *StaticAlloca = DoDynamicAlloca ? nullptr : createAllocaForLayout(IRB, L, false); |