Skip to content

Commit c5b260d

Browse files
committed
Rollback of rL355585.
Introduces memory leak in FunctionTest.GetPointerAlignment that breaks sanitizer buildbots: ``` ================================================================= ==2453==ERROR: LeakSanitizer: detected memory leaks Direct leak of 128 byte(s) in 1 object(s) allocated from: #0 0x610428 in operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105 #1 0x16936bc in llvm::User::operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/User.cpp:151:19 #2 0x7c3fe9 in Create /b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:12 ROCm#3 0x7c3fe9 in (anonymous namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136 ROCm#4 0x1a836a0 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#5 0x1a836a0 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 ROCm#6 0x1a85c55 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 ROCm#7 0x1a870d0 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 ROCm#8 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 ROCm#9 0x1aa4d30 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#10 0x1aa4d30 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 ROCm#11 0x1a6b656 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 ROCm#12 0x1a6b656 in main /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50 ROCm#13 0x7f5af37a22e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) Indirect leak of 40 byte(s) in 1 object(s) allocated from: #0 0x610428 in operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105 #1 0x151be6b in make_unique<llvm::ValueSymbolTable> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1349:29 #2 0x151be6b in llvm::Function::Function(llvm::FunctionType*, llvm::GlobalValue::LinkageTypes, unsigned int, llvm::Twine const&, llvm::Module*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/Function.cpp:241 ROCm#3 0x7c4006 in Create /b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:16 ROCm#4 0x7c4006 in (anonymous namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136 ROCm#5 0x1a836a0 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#6 0x1a836a0 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 ROCm#7 0x1a85c55 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 ROCm#8 0x1a870d0 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 ROCm#9 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 ROCm#10 0x1aa4d30 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#11 0x1aa4d30 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 ROCm#12 0x1a6b656 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 ROCm#13 0x1a6b656 in main /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50 ROCm#14 0x7f5af37a22e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) SUMMARY: AddressSanitizer: 168 byte(s) leaked in 2 allocation(s). ``` See http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11358/steps/check-llvm%20asan/logs/stdio for more information. Also introduces use-of-uninitialized-value in ConstantsTest.FoldGlobalVariablePtr: ``` ==7070==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x14e703c in User /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/User.h:79:5 #1 0x14e703c in Constant /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/Constant.h:44 #2 0x14e703c in llvm::GlobalValue::GlobalValue(llvm::Type*, llvm::Value::ValueTy, llvm::Use*, unsigned int, llvm::GlobalValue::LinkageTypes, llvm::Twine const&, unsigned int) /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/GlobalValue.h:78 ROCm#3 0x14e5467 in GlobalObject /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/GlobalObject.h:34:9 ROCm#4 0x14e5467 in llvm::GlobalVariable::GlobalVariable(llvm::Type*, bool, llvm::GlobalValue::LinkageTypes, llvm::Constant*, llvm::Twine const&, llvm::GlobalValue::ThreadLocalMode, unsigned int, bool) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/Globals.cpp:314 ROCm#5 0x6938f1 in llvm::(anonymous namespace)::ConstantsTest_FoldGlobalVariablePtr_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/IR/ConstantsTest.cpp:565:18 ROCm#6 0x1a240a1 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#7 0x1a240a1 in testing::Test::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 ROCm#8 0x1a26d26 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 ROCm#9 0x1a2815f in testing::TestCase::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 ROCm#10 0x1a43de8 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 ROCm#11 0x1a42c47 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc ROCm#12 0x1a42c47 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 ROCm#13 0x1a0dfba in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 ROCm#14 0x1a0dfba in main /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50 ROCm#15 0x7f2081c412e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) ROCm#16 0x4dff49 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/unittests/IR/IRTests+0x4dff49) SUMMARY: MemorySanitizer: use-of-uninitialized-value /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/User.h:79:5 in User ``` See http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/30222/steps/check-llvm%20msan/logs/stdio for more information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355616 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b11b60d commit c5b260d

File tree

10 files changed

+8
-261
lines changed

10 files changed

+8
-261
lines changed

docs/LangRef.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,14 +2004,6 @@ as follows:
20042004
targets.
20052005
``a:<abi>:<pref>``
20062006
This specifies the alignment for an object of aggregate type.
2007-
``F<type><abi>``
2008-
This specifies the alignment for function pointers.
2009-
The options for ``<type>`` are:
2010-
2011-
* ``i``: The alignment of function pointers is independent of the alignment
2012-
of functions, and is a multiple of ``<abi>``.
2013-
* ``n``: The alignment of function pointers is a multiple of the explicit
2014-
alignment specified on the function, and is a multiple of ``<abi>``.
20152007
``m:<mangling>``
20162008
If present, specifies that llvm names are mangled in the output. Symbols
20172009
prefixed with the mangling escape character ``\01`` are passed through

include/llvm/IR/DataLayout.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ struct PointerAlignElem {
108108
/// generating LLVM IR is required to generate the right target data for the
109109
/// target being codegen'd to.
110110
class DataLayout {
111-
public:
112-
enum class FunctionPtrAlignType {
113-
/// The function pointer alignment is independent of the function alignment.
114-
Independent,
115-
/// The function pointer alignment is a multiple of the function alignment.
116-
MultipleOfFunctionAlign,
117-
};
118111
private:
119112
/// Defaults to false.
120113
bool BigEndian;
@@ -123,9 +116,6 @@ class DataLayout {
123116
unsigned StackNaturalAlign;
124117
unsigned ProgramAddrSpace;
125118

126-
unsigned FunctionPtrAlign;
127-
FunctionPtrAlignType TheFunctionPtrAlignType;
128-
129119
enum ManglingModeT {
130120
MM_None,
131121
MM_ELF,
@@ -209,8 +199,6 @@ class DataLayout {
209199
BigEndian = DL.isBigEndian();
210200
AllocaAddrSpace = DL.AllocaAddrSpace;
211201
StackNaturalAlign = DL.StackNaturalAlign;
212-
FunctionPtrAlign = DL.FunctionPtrAlign;
213-
TheFunctionPtrAlignType = DL.TheFunctionPtrAlignType;
214202
ProgramAddrSpace = DL.ProgramAddrSpace;
215203
ManglingMode = DL.ManglingMode;
216204
LegalIntWidths = DL.LegalIntWidths;
@@ -268,17 +256,6 @@ class DataLayout {
268256
unsigned getStackAlignment() const { return StackNaturalAlign; }
269257
unsigned getAllocaAddrSpace() const { return AllocaAddrSpace; }
270258

271-
/// Returns the alignment of function pointers, which may or may not be
272-
/// related to the alignment of functions.
273-
/// \see getFunctionPtrAlignType
274-
unsigned getFunctionPtrAlign() const { return FunctionPtrAlign; }
275-
276-
/// Return the type of function pointer alignment.
277-
/// \see getFunctionPtrAlign
278-
FunctionPtrAlignType getFunctionPtrAlignType() const {
279-
return TheFunctionPtrAlignType;
280-
}
281-
282259
unsigned getProgramAddressSpace() const { return ProgramAddrSpace; }
283260

284261
bool hasMicrosoftFastStdCallMangling() const {

lib/IR/ConstantFold.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "llvm/IR/GlobalAlias.h"
2727
#include "llvm/IR/GlobalVariable.h"
2828
#include "llvm/IR/Instructions.h"
29-
#include "llvm/IR/Module.h"
3029
#include "llvm/IR/Operator.h"
3130
#include "llvm/IR/PatternMatch.h"
3231
#include "llvm/Support/ErrorHandling.h"
@@ -1077,29 +1076,10 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
10771076
isa<GlobalValue>(CE1->getOperand(0))) {
10781077
GlobalValue *GV = cast<GlobalValue>(CE1->getOperand(0));
10791078

1080-
unsigned GVAlign;
1081-
1082-
if (Module *TheModule = GV->getParent()) {
1083-
GVAlign = GV->getPointerAlignment(TheModule->getDataLayout());
1084-
1085-
// If the function alignment is not specified then assume that it
1086-
// is 4.
1087-
// This is dangerous; on x86, the alignment of the pointer
1088-
// corresponds to the alignment of the function, but might be less
1089-
// than 4 if it isn't explicitly specified.
1090-
// However, a fix for this behaviour was reverted because it
1091-
// increased code size (see https://reviews.llvm.org/D55115)
1092-
// FIXME: This code should be deleted once existing targets have
1093-
// appropriate defaults
1094-
if (GVAlign == 0U && isa<Function>(GV))
1095-
GVAlign = 4U;
1096-
} else if (isa<Function>(GV)) {
1097-
// Without a datalayout we have to assume the worst case: that the
1098-
// function pointer isn't aligned at all.
1099-
GVAlign = 0U;
1100-
} else {
1101-
GVAlign = GV->getAlignment();
1102-
}
1079+
// Functions are at least 4-byte aligned.
1080+
unsigned GVAlign = GV->getAlignment();
1081+
if (isa<Function>(GV))
1082+
GVAlign = std::max(GVAlign, 4U);
11031083

11041084
if (GVAlign > 1) {
11051085
unsigned DstWidth = CI2->getType()->getBitWidth();

lib/IR/DataLayout.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ void DataLayout::reset(StringRef Desc) {
184184
AllocaAddrSpace = 0;
185185
StackNaturalAlign = 0;
186186
ProgramAddrSpace = 0;
187-
FunctionPtrAlign = 0;
188-
TheFunctionPtrAlignType = FunctionPtrAlignType::Independent;
189187
ManglingMode = MM_None;
190188
NonIntegralAddressSpaces.clear();
191189

@@ -381,22 +379,6 @@ void DataLayout::parseSpecifier(StringRef Desc) {
381379
StackNaturalAlign = inBytes(getInt(Tok));
382380
break;
383381
}
384-
case 'F': {
385-
switch (Tok.front()) {
386-
case 'i':
387-
TheFunctionPtrAlignType = FunctionPtrAlignType::Independent;
388-
break;
389-
case 'n':
390-
TheFunctionPtrAlignType = FunctionPtrAlignType::MultipleOfFunctionAlign;
391-
break;
392-
default:
393-
report_fatal_error("Unknown function pointer alignment type in "
394-
"datalayout string");
395-
}
396-
Tok = Tok.substr(1);
397-
FunctionPtrAlign = inBytes(getInt(Tok));
398-
break;
399-
}
400382
case 'P': { // Function address space.
401383
ProgramAddrSpace = getAddrSpace(Tok);
402384
break;
@@ -450,8 +432,6 @@ bool DataLayout::operator==(const DataLayout &Other) const {
450432
AllocaAddrSpace == Other.AllocaAddrSpace &&
451433
StackNaturalAlign == Other.StackNaturalAlign &&
452434
ProgramAddrSpace == Other.ProgramAddrSpace &&
453-
FunctionPtrAlign == Other.FunctionPtrAlign &&
454-
TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType &&
455435
ManglingMode == Other.ManglingMode &&
456436
LegalIntWidths == Other.LegalIntWidths &&
457437
Alignments == Other.Alignments && Pointers == Other.Pointers;

lib/IR/Value.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,10 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const {
648648

649649
unsigned Align = 0;
650650
if (auto *GO = dyn_cast<GlobalObject>(this)) {
651-
if (isa<Function>(GO)) {
652-
switch (DL.getFunctionPtrAlignType()) {
653-
case DataLayout::FunctionPtrAlignType::Independent:
654-
return DL.getFunctionPtrAlign();
655-
case DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign:
656-
return std::max(DL.getFunctionPtrAlign(), GO->getAlignment());
657-
}
658-
}
651+
// Don't make any assumptions about function pointer alignment. Some
652+
// targets use the LSBs to store additional information.
653+
if (isa<Function>(GO))
654+
return 0;
659655
Align = GO->getAlignment();
660656
if (Align == 0) {
661657
if (auto *GVar = dyn_cast<GlobalVariable>(GO)) {

lib/Target/ARM/ARMTargetMachine.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU,
141141
// Pointers are 32 bits and aligned to 32 bits.
142142
Ret += "-p:32:32";
143143

144-
// Function pointers are aligned to 8 bits (because the LSB stores the
145-
// ARM/Thumb state).
146-
Ret += "-Fi8";
147-
148144
// ABIs other than APCS have 64 bit integers with natural alignment.
149145
if (ABI != ARMBaseTargetMachine::ARM_ABI_APCS)
150146
Ret += "-i64:64";

unittests/IR/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ add_llvm_unittest(IRTests
1313
CFGBuilder.cpp
1414
ConstantRangeTest.cpp
1515
ConstantsTest.cpp
16-
DataLayoutTest.cpp
1716
DebugInfoTest.cpp
1817
DebugTypeODRUniquingTest.cpp
1918
DominatorTreeTest.cpp

unittests/IR/ConstantsTest.cpp

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -475,106 +475,5 @@ TEST(ConstantsTest, BitcastToGEP) {
475475
ASSERT_EQ(cast<ConstantExpr>(C)->getOpcode(), Instruction::BitCast);
476476
}
477477

478-
bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
479-
uint64_t AndValue, unsigned FunctionAlign = 0) {
480-
Type *VoidType(Type::getVoidTy(Context));
481-
FunctionType *FuncType(FunctionType::get(VoidType, false));
482-
Function *Func(Function::Create(
483-
FuncType, GlobalValue::ExternalLinkage, "", TheModule));
484-
485-
if (FunctionAlign) Func->setAlignment(FunctionAlign);
486-
487-
IntegerType *ConstantIntType(Type::getInt32Ty(Context));
488-
ConstantInt *TheConstant(ConstantInt::get(ConstantIntType, AndValue));
489-
490-
Constant *TheConstantExpr(
491-
ConstantExpr::getPtrToInt(Func, ConstantIntType));
492-
493-
return ConstantExpr::get(Instruction::And, TheConstantExpr,
494-
TheConstant)->isNullValue();
495-
}
496-
497-
TEST(ConstantsTest, FoldFunctionPtrAlignUnknownAnd2) {
498-
LLVMContext Context;
499-
Module TheModule("TestModule", Context);
500-
// When the DataLayout doesn't specify a function pointer alignment we
501-
// assume in this case that it is 4 byte aligned. This is a bug but we can't
502-
// fix it directly because it causes a code size regression on X86.
503-
// FIXME: This test should be changed once existing targets have
504-
// appropriate defaults. See associated FIXME in ConstantFoldBinaryInstruction
505-
ASSERT_TRUE(foldFuncPtrAndConstToNull(Context, &TheModule, 2));
506-
}
507-
508-
TEST(ConstantsTest, DontFoldFunctionPtrAlignUnknownAnd4) {
509-
LLVMContext Context;
510-
Module TheModule("TestModule", Context);
511-
ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, &TheModule, 4));
512-
}
513-
514-
TEST(ConstantsTest, FoldFunctionPtrAlign4) {
515-
LLVMContext Context;
516-
Module TheModule("TestModule", Context);
517-
const char* AlignmentStrings[] = { "Fi32", "Fn32" };
518-
519-
for (unsigned AndValue = 1; AndValue <= 2; ++AndValue) {
520-
for (const char *AlignmentString : AlignmentStrings) {
521-
TheModule.setDataLayout(AlignmentString);
522-
ASSERT_TRUE(foldFuncPtrAndConstToNull(Context, &TheModule, AndValue));
523-
}
524-
}
525-
}
526-
527-
TEST(ConstantsTest, DontFoldFunctionPtrAlign1) {
528-
LLVMContext Context;
529-
Module TheModule("TestModule", Context);
530-
const char* AlignmentStrings[] = { "Fi8", "Fn8" };
531-
532-
for (const char* AlignmentString : AlignmentStrings) {
533-
TheModule.setDataLayout(AlignmentString);
534-
ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, &TheModule, 2));
535-
}
536-
}
537-
538-
TEST(ConstantsTest, FoldFunctionAlign4PtrAlignMultiple) {
539-
LLVMContext Context;
540-
Module TheModule("TestModule", Context);
541-
TheModule.setDataLayout("Fn8");
542-
ASSERT_TRUE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, 4));
543-
}
544-
545-
TEST(ConstantsTest, DontFoldFunctionAlign4PtrAlignIndependent) {
546-
LLVMContext Context;
547-
Module TheModule("TestModule", Context);
548-
TheModule.setDataLayout("Fi8");
549-
ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, 4));
550-
}
551-
552-
TEST(ConstantsTest, DontFoldFunctionPtrIfNoModule) {
553-
LLVMContext Context;
554-
// Even though the function is explicitly 4 byte aligned, in the absence of a
555-
// DataLayout we can't assume that the function pointer is aligned.
556-
ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, nullptr, 2, 4));
557-
}
558-
559-
TEST(ConstantsTest, FoldGlobalVariablePtr) {
560-
LLVMContext Context;
561-
562-
563-
IntegerType *IntType(Type::getInt32Ty(Context));
564-
565-
std::unique_ptr<GlobalVariable> Global(
566-
new GlobalVariable(IntType, true, GlobalValue::ExternalLinkage));
567-
568-
Global->setAlignment(4);
569-
570-
ConstantInt *TheConstant(ConstantInt::get(IntType, 2));
571-
572-
Constant *TheConstantExpr(
573-
ConstantExpr::getPtrToInt(Global.get(), IntType));
574-
575-
ASSERT_TRUE(ConstantExpr::get( \
576-
Instruction::And, TheConstantExpr, TheConstant)->isNullValue());
577-
}
578-
579478
} // end anonymous namespace
580479
} // end namespace llvm

unittests/IR/DataLayoutTest.cpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

unittests/IR/FunctionTest.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,4 @@ TEST(FunctionTest, setSection) {
129129
EXPECT_TRUE(F->hasSection());
130130
}
131131

132-
TEST(FunctionTest, GetPointerAlignment) {
133-
LLVMContext Context;
134-
Type *VoidType(Type::getVoidTy(Context));
135-
FunctionType *FuncType(FunctionType::get(VoidType, false));
136-
Function *Func = Function::Create(
137-
FuncType, GlobalValue::ExternalLinkage);
138-
EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
139-
EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
140-
EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fn8")));
141-
EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
142-
EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fn16")));
143-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
144-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
145-
146-
Func->setAlignment(4U);
147-
148-
EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
149-
EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
150-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn8")));
151-
EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
152-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn16")));
153-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
154-
EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
155-
}
156-
157132
} // end namespace

0 commit comments

Comments
 (0)