[PATCH] D90258: [InstCombine] Do not introduce bitcasts for swifterror arguments.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 27 11:56:17 PDT 2020
fhahn created this revision.
fhahn added reviewers: spatel, lebedev.ri, rjmccall, xbolva00.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
fhahn requested review of this revision.
The following constraints hold for swifterror values:
A swifterror value (either the parameter or the alloca) can only
be loaded and stored from, or used as a swifterror argument.
This patch updates instcombine to not try to convert a bitcast of a
function into a bitcast of a swifterror argument.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90258
Files:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/swifterror-argument-bitcast-fold.ll
Index: llvm/test/Transforms/InstCombine/swifterror-argument-bitcast-fold.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/swifterror-argument-bitcast-fold.ll
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; opt -instcombine -S %s | FileCheck %s
+
+; The swifterror value can only be loaded, stored or used as swifterror
+; argument. Make sure we do not try to turn the function bitcast into an
+; argument bitcast.
+define swiftcc void @spam(i32** swifterror %arg) {
+bb:
+ call swiftcc void bitcast (void (i64**)* @widget to void (i32**)*)(i32** swifterror %arg)
+ ret void
+}
+
+declare swiftcc void @widget(i64**)
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2126,6 +2126,9 @@
if (Call.isInAllocaArgument(i))
return false; // Cannot transform to and from inalloca.
+ if (CallerPAL.hasParamAttribute(i, Attribute::SwiftError))
+ return false;
+
// If the parameter is passed as a byval argument, then we have to have a
// sized type and the sized type has to have the same size as the old type.
if (ParamTy != ActTy && CallerPAL.hasParamAttribute(i, Attribute::ByVal)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90258.301075.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/56c7b239/attachment.bin>
More information about the llvm-commits
mailing list