[LLVMbugs] [Bug 18163] New: [Inline] Functions not inlined due to flag -Oz is not emitted
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Dec 6 17:54:18 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=18163
Bug ID: 18163
Summary: [Inline] Functions not inlined due to flag -Oz is not
emitted
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: zhaoshiz at codeaurora.org
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11684
--> http://llvm.org/bugs/attachment.cgi?id=11684&action=edit
LLVM-IR generated with -Oz
This bug is causing "undefined reference" error at link time. It seems the
inliner is doing fine, please see attached test case.
$ cat test.h
extern int MAX_LEN;
extern int MIN_LEN;
extern int MAX_KEY;
struct HashTable;
extern struct HashTable* HT;
int HashAdd(struct HashTable* HT, int key, char* str);
int HashRemove(struct HashTable* HT, int key);
int hash(char* str, int len);
inline void goo (char* str, int len) {
if (len <= MAX_LEN && len >= MIN_LEN) {
int key = hash(str, len);
if (key <= MAX_LEN && key >= 0)
while (HashAdd(HT, key, str))
HashRemove(HT, key);
}
}
$ cat test.c
#include <string.h>
#include "test.h"
int MAX_LEN;
int MIN_LEN;
int MAX_KEY;
struct HashTable;
struct HashTable* HT;
int main (int argc, char* argv[]) {
unsigned i;
for (i=0; i<argc; ++i) {
int arglen = strlen(argv[i]);
goo (argv[i], arglen < MAX_LEN ? arglen : MAX_LEN);
}
}
$ cat Oz.s
.syntax unified
.cpu cortex-a9
.eabi_attribute 6, 10
.eabi_attribute 7, 65
.eabi_attribute 8, 1
.eabi_attribute 9, 2
.fpu neon
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 36, 1
.eabi_attribute 68, 1
.file "./test.c"
.text
.globl main
.align 2
.type main,%function
.code 16
.thumb_func
main:
push.w {r4, r5, r6, r7, r11, lr}
mov r5, r0
mov r4, r1
cbz r5, .LBB0_3
ldr r7, .LCPI0_0
.LBB0_2:
ldr r6, [r4], #4
mov r0, r6
bl strlen
ldr r1, [r7]
cmp r0, r1
it lt
movlt r1, r0
mov r0, r6
bl goo
subs r5, #1
bne .LBB0_2
.LBB0_3:
movs r0, #0
pop.w {r4, r5, r6, r7, r11, pc}
.align 2
.LCPI0_0:
.long MAX_LEN
.Ltmp0:
.size main, .Ltmp0-main
.type MAX_LEN,%object
.comm MAX_LEN,4,4
.type MIN_LEN,%object
.comm MIN_LEN,4,4
.type MAX_KEY,%object
.comm MAX_KEY,4,4
.type HT,%object
.comm HT,4,4
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131207/1ec737c8/attachment.html>
More information about the llvm-bugs
mailing list