[llvm] r346256 - [CodeExtractor] Do not extract calls to eh_typeid_for (PR39545)
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 6 11:06:08 PST 2018
Author: vedantk
Date: Tue Nov 6 11:06:08 2018
New Revision: 346256
URL: http://llvm.org/viewvc/llvm-project?rev=346256&view=rev
Log:
[CodeExtractor] Do not extract calls to eh_typeid_for (PR39545)
The lowering for a call to eh_typeid_for changes when it's moved from
one function to another.
There are several proposals for fixing this issue in llvm.org/PR39545.
Until some solution is in place, do not allow CodeExtractor to extract
calls to eh_typeid_for, as that results in serious miscompilations.
Added:
llvm/trunk/test/Transforms/HotColdSplit/eh-typeid-for.ll
Modified:
llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=346256&r1=346255&r2=346256&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Tue Nov 6 11:06:08 2018
@@ -168,14 +168,22 @@ static bool isBlockValidForExtraction(co
continue;
}
- if (const CallInst *CI = dyn_cast<CallInst>(I))
- if (const Function *F = CI->getCalledFunction())
- if (F->getIntrinsicID() == Intrinsic::vastart) {
+ if (const CallInst *CI = dyn_cast<CallInst>(I)) {
+ if (const Function *F = CI->getCalledFunction()) {
+ auto IID = F->getIntrinsicID();
+ if (IID == Intrinsic::vastart) {
if (AllowVarArgs)
continue;
else
return false;
}
+
+ // Currently, we miscompile outlined copies of eh_typid_for. There are
+ // proposals for fixing this in llvm.org/PR39545.
+ if (IID == Intrinsic::eh_typeid_for)
+ return false;
+ }
+ }
}
return true;
Added: llvm/trunk/test/Transforms/HotColdSplit/eh-typeid-for.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/eh-typeid-for.ll?rev=346256&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/eh-typeid-for.ll (added)
+++ llvm/trunk/test/Transforms/HotColdSplit/eh-typeid-for.ll Tue Nov 6 11:06:08 2018
@@ -0,0 +1,26 @@
+; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+
+; Do not outline calls to @llvm.eh.typeid.for. See llvm.org/PR39545.
+
+ at _ZTIi = external constant i8*
+
+; CHECK-LABEL: @fun
+; CHECK-NOT: call {{.*}}@fun.cold.1
+define void @fun() {
+entry:
+ br i1 undef, label %if.then, label %if.else
+
+if.then:
+ ret void
+
+if.else:
+ %t = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+ call void @sink()
+ call void @sink()
+ call void @sink()
+ ret void
+}
+
+declare void @sink() cold
+
+declare i32 @llvm.eh.typeid.for(i8*)
More information about the llvm-commits
mailing list