@@ -1847,6 +1847,12 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1847
1847
Args.push_back (ConstantInt::get (DL.getIntPtrType (Ctx), Size ));
1848
1848
}
1849
1849
1850
+ bool bShouldDisableLifetimeMarker = false ;
1851
+
1852
+ if (I->getParent () && I->getParent ()->getParent () && I->getParent ()->getParent ()->hasSEHOrCXXSEH ()) {
1853
+ bShouldDisableLifetimeMarker = true ;
1854
+ }
1855
+
1850
1856
// 'ptr' argument.
1851
1857
// note: This assumes all address spaces share a common libfunc
1852
1858
// implementation and that addresses are convertable. For systems without
@@ -1860,9 +1866,11 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1860
1866
if (CASExpected) {
1861
1867
AllocaCASExpected = AllocaBuilder.CreateAlloca (CASExpected->getType ());
1862
1868
AllocaCASExpected->setAlignment (AllocaAlignment);
1863
- #ifndef _WIN32
1864
- Builder.CreateLifetimeStart (AllocaCASExpected, SizeVal64);
1865
- #endif
1869
+ if (!bShouldDisableLifetimeMarker) {
1870
+
1871
+ Builder.CreateLifetimeStart (AllocaCASExpected, SizeVal64);
1872
+ }
1873
+
1866
1874
Builder.CreateAlignedStore (CASExpected, AllocaCASExpected, AllocaAlignment);
1867
1875
Args.push_back (AllocaCASExpected);
1868
1876
}
@@ -1876,9 +1884,10 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1876
1884
} else {
1877
1885
AllocaValue = AllocaBuilder.CreateAlloca (ValueOperand->getType ());
1878
1886
AllocaValue->setAlignment (AllocaAlignment);
1879
- #ifndef _WIN32
1880
- Builder.CreateLifetimeStart (AllocaValue, SizeVal64);
1881
- #endif
1887
+ if (!bShouldDisableLifetimeMarker) {
1888
+ Builder.CreateLifetimeStart (AllocaValue, SizeVal64);
1889
+ }
1890
+
1882
1891
Builder.CreateAlignedStore (ValueOperand, AllocaValue, AllocaAlignment);
1883
1892
Args.push_back (AllocaValue);
1884
1893
}
@@ -1888,9 +1897,10 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1888
1897
if (!CASExpected && HasResult && !UseSizedLibcall) {
1889
1898
AllocaResult = AllocaBuilder.CreateAlloca (I->getType ());
1890
1899
AllocaResult->setAlignment (AllocaAlignment);
1891
- #ifndef _WIN32
1892
- Builder.CreateLifetimeStart (AllocaResult, SizeVal64);
1893
- #endif
1900
+ if (!bShouldDisableLifetimeMarker) {
1901
+ Builder.CreateLifetimeStart (AllocaResult, SizeVal64);
1902
+ }
1903
+
1894
1904
Args.push_back (AllocaResult);
1895
1905
}
1896
1906
@@ -1920,21 +1930,21 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1920
1930
CallInst *Call = Builder.CreateCall (LibcallFn, Args);
1921
1931
Call->setAttributes (Attr);
1922
1932
Value *Result = Call;
1923
- # ifndef _WIN32
1924
- // And then, extract the results...
1925
- if (ValueOperand && !UseSizedLibcall)
1926
- Builder.CreateLifetimeEnd (AllocaValue, SizeVal64);
1927
- # endif
1933
+ if (!bShouldDisableLifetimeMarker) {
1934
+ // And then, extract the results...
1935
+ if (ValueOperand && !UseSizedLibcall)
1936
+ Builder.CreateLifetimeEnd (AllocaValue, SizeVal64);
1937
+ }
1928
1938
if (CASExpected) {
1929
1939
// The final result from the CAS is {load of 'expected' alloca, bool result
1930
1940
// from call}
1931
1941
Type *FinalResultTy = I->getType ();
1932
1942
Value *V = PoisonValue::get (FinalResultTy);
1933
1943
Value *ExpectedOut = Builder.CreateAlignedLoad (
1934
1944
CASExpected->getType (), AllocaCASExpected, AllocaAlignment);
1935
- # ifndef _WIN32
1936
- Builder.CreateLifetimeEnd (AllocaCASExpected, SizeVal64);
1937
- # endif
1945
+ if (!bShouldDisableLifetimeMarker) {
1946
+ Builder.CreateLifetimeEnd (AllocaCASExpected, SizeVal64);
1947
+ }
1938
1948
V = Builder.CreateInsertValue (V, ExpectedOut, 0 );
1939
1949
V = Builder.CreateInsertValue (V, Result, 1 );
1940
1950
I->replaceAllUsesWith (V);
@@ -1945,9 +1955,9 @@ bool AtomicExpand::expandAtomicOpToLibcall(
1945
1955
else {
1946
1956
V = Builder.CreateAlignedLoad (I->getType (), AllocaResult,
1947
1957
AllocaAlignment);
1948
- # ifndef _WIN32
1949
- Builder.CreateLifetimeEnd (AllocaResult, SizeVal64);
1950
- # endif
1958
+ if (!bShouldDisableLifetimeMarker) {
1959
+ Builder.CreateLifetimeEnd (AllocaResult, SizeVal64);
1960
+ }
1951
1961
}
1952
1962
I->replaceAllUsesWith (V);
1953
1963
}
0 commit comments